From 693158f765d33fd7352f1e450ae7487da4cc0739 Mon Sep 17 00:00:00 2001 From: Bui Quang Minh Date: Sun, 13 Jun 2021 21:34:39 +0700 Subject: [PATCH 01/48] UPSTREAM: bpf: Fix integer overflow in argument calculation for bpf_map_area_alloc commit 7dd5d437c258bbf4cc15b35229e5208b87b8b4e0 upstream. In 32-bit architecture, the result of sizeof() is a 32-bit integer so the expression becomes the multiplication between 2 32-bit integer which can potentially leads to integer overflow. As a result, bpf_map_area_alloc() allocates less memory than needed. Fix this by casting 1 operand to u64. Fixes: 0d2c4f964050 ("bpf: Eliminate rlimit-based memory accounting for sockmap and sockhash maps") Fixes: 99c51064fb06 ("devmap: Use bpf_map_area_alloc() for allocating hash buckets") Fixes: 546ac1ffb70d ("bpf: add devmap, a map for storing net device references") Signed-off-by: Bui Quang Minh Signed-off-by: Alexei Starovoitov Link: https://lore.kernel.org/bpf/20210613143440.71975-1-minhquangbui99@gmail.com Signed-off-by: Connor O'Brien Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Change-Id: I9ce1991224a87eb39acf1da4923534e22380fc42 --- kernel/bpf/devmap.c | 4 ++-- net/core/sock_map.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c index 6684696fa457..4b2819b0a05a 100644 --- a/kernel/bpf/devmap.c +++ b/kernel/bpf/devmap.c @@ -94,7 +94,7 @@ static struct hlist_head *dev_map_create_hash(unsigned int entries, int i; struct hlist_head *hash; - hash = bpf_map_area_alloc(entries * sizeof(*hash), numa_node); + hash = bpf_map_area_alloc((u64) entries * sizeof(*hash), numa_node); if (hash != NULL) for (i = 0; i < entries; i++) INIT_HLIST_HEAD(&hash[i]); @@ -159,7 +159,7 @@ static int dev_map_init_map(struct bpf_dtab *dtab, union bpf_attr *attr) spin_lock_init(&dtab->index_lock); } else { - dtab->netdev_map = bpf_map_area_alloc(dtab->map.max_entries * + dtab->netdev_map = bpf_map_area_alloc((u64) dtab->map.max_entries * sizeof(struct bpf_dtab_netdev *), dtab->map.numa_node); if (!dtab->netdev_map) diff --git a/net/core/sock_map.c b/net/core/sock_map.c index df52061f99f7..2646e8f98f67 100644 --- a/net/core/sock_map.c +++ b/net/core/sock_map.c @@ -48,7 +48,7 @@ static struct bpf_map *sock_map_alloc(union bpf_attr *attr) if (err) goto free_stab; - stab->sks = bpf_map_area_alloc(stab->map.max_entries * + stab->sks = bpf_map_area_alloc((u64) stab->map.max_entries * sizeof(struct sock *), stab->map.numa_node); if (stab->sks) From f1a1171f3c5912e7b5911488d15065f2598fca5b Mon Sep 17 00:00:00 2001 From: Jens Wiklander Date: Thu, 9 Dec 2021 15:59:37 +0100 Subject: [PATCH 02/48] UPSTREAM: tee: handle lookup of shm with reference count 0 commit dfd0743f1d9ea76931510ed150334d571fbab49d upstream. Since the tee subsystem does not keep a strong reference to its idle shared memory buffers, it races with other threads that try to destroy a shared memory through a close of its dma-buf fd or by unmapping the memory. In tee_shm_get_from_id() when a lookup in teedev->idr has been successful, it is possible that the tee_shm is in the dma-buf teardown path, but that path is blocked by the teedev mutex. Since we don't have an API to tell if the tee_shm is in the dma-buf teardown path or not we must find another way of detecting this condition. Fix this by doing the reference counting directly on the tee_shm using a new refcount_t refcount field. dma-buf is replaced by using anon_inode_getfd() instead, this separates the life-cycle of the underlying file from the tee_shm. tee_shm_put() is updated to hold the mutex when decreasing the refcount to 0 and then remove the tee_shm from teedev->idr before releasing the mutex. This means that the tee_shm can never be found unless it has a refcount larger than 0. Fixes: 967c9cca2cc5 ("tee: generic TEE subsystem") Cc: stable@vger.kernel.org Reviewed-by: Greg Kroah-Hartman Reviewed-by: Lars Persson Reviewed-by: Sumit Garg Reported-by: Patrik Lantz [JW: backport to 5.4-stable] Signed-off-by: Jens Wiklander Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Change-Id: Ibd2809a225b167563c65faff4a44e56e23c2e97b --- drivers/tee/tee_shm.c | 177 +++++++++++++++------------------------- include/linux/tee_drv.h | 4 +- 2 files changed, 69 insertions(+), 112 deletions(-) diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c index d6491e973fa4..0d5ae8053049 100644 --- a/drivers/tee/tee_shm.c +++ b/drivers/tee/tee_shm.c @@ -1,26 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2015-2016, Linaro Limited + * Copyright (c) 2015-2017, 2019-2021 Linaro Limited */ +#include #include -#include -#include #include +#include #include #include #include #include "tee_private.h" -static void tee_shm_release(struct tee_shm *shm) +static void tee_shm_release(struct tee_device *teedev, struct tee_shm *shm) { - struct tee_device *teedev = shm->teedev; - - mutex_lock(&teedev->mutex); - idr_remove(&teedev->idr, shm->id); - if (shm->ctx) - list_del(&shm->link); - mutex_unlock(&teedev->mutex); - if (shm->flags & TEE_SHM_POOL) { struct tee_shm_pool_mgr *poolm; @@ -52,51 +44,6 @@ static void tee_shm_release(struct tee_shm *shm) tee_device_put(teedev); } -static struct sg_table *tee_shm_op_map_dma_buf(struct dma_buf_attachment - *attach, enum dma_data_direction dir) -{ - return NULL; -} - -static void tee_shm_op_unmap_dma_buf(struct dma_buf_attachment *attach, - struct sg_table *table, - enum dma_data_direction dir) -{ -} - -static void tee_shm_op_release(struct dma_buf *dmabuf) -{ - struct tee_shm *shm = dmabuf->priv; - - tee_shm_release(shm); -} - -static void *tee_shm_op_map(struct dma_buf *dmabuf, unsigned long pgnum) -{ - return NULL; -} - -static int tee_shm_op_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma) -{ - struct tee_shm *shm = dmabuf->priv; - size_t size = vma->vm_end - vma->vm_start; - - /* Refuse sharing shared memory provided by application */ - if (shm->flags & TEE_SHM_REGISTER) - return -EINVAL; - - return remap_pfn_range(vma, vma->vm_start, shm->paddr >> PAGE_SHIFT, - size, vma->vm_page_prot); -} - -static const struct dma_buf_ops tee_shm_dma_buf_ops = { - .map_dma_buf = tee_shm_op_map_dma_buf, - .unmap_dma_buf = tee_shm_op_unmap_dma_buf, - .release = tee_shm_op_release, - .map = tee_shm_op_map, - .mmap = tee_shm_op_mmap, -}; - static struct tee_shm *__tee_shm_alloc(struct tee_context *ctx, struct tee_device *teedev, size_t size, u32 flags) @@ -137,6 +84,7 @@ static struct tee_shm *__tee_shm_alloc(struct tee_context *ctx, goto err_dev_put; } + refcount_set(&shm->refcount, 1); shm->flags = flags | TEE_SHM_POOL; shm->teedev = teedev; shm->ctx = ctx; @@ -159,21 +107,6 @@ static struct tee_shm *__tee_shm_alloc(struct tee_context *ctx, goto err_pool_free; } - if (flags & TEE_SHM_DMA_BUF) { - DEFINE_DMA_BUF_EXPORT_INFO(exp_info); - - exp_info.ops = &tee_shm_dma_buf_ops; - exp_info.size = shm->size; - exp_info.flags = O_RDWR; - exp_info.priv = shm; - - shm->dmabuf = dma_buf_export(&exp_info); - if (IS_ERR(shm->dmabuf)) { - ret = ERR_CAST(shm->dmabuf); - goto err_rem; - } - } - if (ctx) { teedev_ctx_get(ctx); mutex_lock(&teedev->mutex); @@ -182,10 +115,6 @@ static struct tee_shm *__tee_shm_alloc(struct tee_context *ctx, } return shm; -err_rem: - mutex_lock(&teedev->mutex); - idr_remove(&teedev->idr, shm->id); - mutex_unlock(&teedev->mutex); err_pool_free: poolm->ops->free(poolm, shm); err_kfree: @@ -268,6 +197,7 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr, goto err; } + refcount_set(&shm->refcount, 1); shm->flags = flags | TEE_SHM_REGISTER; shm->teedev = teedev; shm->ctx = ctx; @@ -309,22 +239,6 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr, goto err; } - if (flags & TEE_SHM_DMA_BUF) { - DEFINE_DMA_BUF_EXPORT_INFO(exp_info); - - exp_info.ops = &tee_shm_dma_buf_ops; - exp_info.size = shm->size; - exp_info.flags = O_RDWR; - exp_info.priv = shm; - - shm->dmabuf = dma_buf_export(&exp_info); - if (IS_ERR(shm->dmabuf)) { - ret = ERR_CAST(shm->dmabuf); - teedev->desc->ops->shm_unregister(ctx, shm); - goto err; - } - } - mutex_lock(&teedev->mutex); list_add_tail(&shm->link, &ctx->list_shm); mutex_unlock(&teedev->mutex); @@ -352,6 +266,35 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr, } EXPORT_SYMBOL_GPL(tee_shm_register); +static int tee_shm_fop_release(struct inode *inode, struct file *filp) +{ + tee_shm_put(filp->private_data); + return 0; +} + +static int tee_shm_fop_mmap(struct file *filp, struct vm_area_struct *vma) +{ + struct tee_shm *shm = filp->private_data; + size_t size = vma->vm_end - vma->vm_start; + + /* Refuse sharing shared memory provided by application */ + if (shm->flags & TEE_SHM_USER_MAPPED) + return -EINVAL; + + /* check for overflowing the buffer's size */ + if (vma->vm_pgoff + vma_pages(vma) > shm->size >> PAGE_SHIFT) + return -EINVAL; + + return remap_pfn_range(vma, vma->vm_start, shm->paddr >> PAGE_SHIFT, + size, vma->vm_page_prot); +} + +static const struct file_operations tee_shm_fops = { + .owner = THIS_MODULE, + .release = tee_shm_fop_release, + .mmap = tee_shm_fop_mmap, +}; + /** * tee_shm_get_fd() - Increase reference count and return file descriptor * @shm: Shared memory handle @@ -364,10 +307,11 @@ int tee_shm_get_fd(struct tee_shm *shm) if (!(shm->flags & TEE_SHM_DMA_BUF)) return -EINVAL; - get_dma_buf(shm->dmabuf); - fd = dma_buf_fd(shm->dmabuf, O_CLOEXEC); + /* matched by tee_shm_put() in tee_shm_op_release() */ + refcount_inc(&shm->refcount); + fd = anon_inode_getfd("tee_shm", &tee_shm_fops, shm, O_RDWR); if (fd < 0) - dma_buf_put(shm->dmabuf); + tee_shm_put(shm); return fd; } @@ -377,17 +321,7 @@ int tee_shm_get_fd(struct tee_shm *shm) */ void tee_shm_free(struct tee_shm *shm) { - /* - * dma_buf_put() decreases the dmabuf reference counter and will - * call tee_shm_release() when the last reference is gone. - * - * In the case of driver private memory we call tee_shm_release - * directly instead as it doesn't have a reference counter. - */ - if (shm->flags & TEE_SHM_DMA_BUF) - dma_buf_put(shm->dmabuf); - else - tee_shm_release(shm); + tee_shm_put(shm); } EXPORT_SYMBOL_GPL(tee_shm_free); @@ -494,10 +428,15 @@ struct tee_shm *tee_shm_get_from_id(struct tee_context *ctx, int id) teedev = ctx->teedev; mutex_lock(&teedev->mutex); shm = idr_find(&teedev->idr, id); + /* + * If the tee_shm was found in the IDR it must have a refcount + * larger than 0 due to the guarantee in tee_shm_put() below. So + * it's safe to use refcount_inc(). + */ if (!shm || shm->ctx != ctx) shm = ERR_PTR(-EINVAL); - else if (shm->flags & TEE_SHM_DMA_BUF) - get_dma_buf(shm->dmabuf); + else + refcount_inc(&shm->refcount); mutex_unlock(&teedev->mutex); return shm; } @@ -509,7 +448,25 @@ EXPORT_SYMBOL_GPL(tee_shm_get_from_id); */ void tee_shm_put(struct tee_shm *shm) { - if (shm->flags & TEE_SHM_DMA_BUF) - dma_buf_put(shm->dmabuf); + struct tee_device *teedev = shm->teedev; + bool do_release = false; + + mutex_lock(&teedev->mutex); + if (refcount_dec_and_test(&shm->refcount)) { + /* + * refcount has reached 0, we must now remove it from the + * IDR before releasing the mutex. This will guarantee that + * the refcount_inc() in tee_shm_get_from_id() never starts + * from 0. + */ + idr_remove(&teedev->idr, shm->id); + if (shm->ctx) + list_del(&shm->link); + do_release = true; + } + mutex_unlock(&teedev->mutex); + + if (do_release) + tee_shm_release(teedev, shm); } EXPORT_SYMBOL_GPL(tee_shm_put); diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h index cd15c1b7fae0..e08ace76eba6 100644 --- a/include/linux/tee_drv.h +++ b/include/linux/tee_drv.h @@ -178,7 +178,7 @@ void tee_device_unregister(struct tee_device *teedev); * @offset: offset of buffer in user space * @pages: locked pages from userspace * @num_pages: number of locked pages - * @dmabuf: dmabuf used to for exporting to user space + * @refcount: reference counter * @flags: defined by TEE_SHM_* in tee_drv.h * @id: unique id of a shared memory object on this device * @@ -195,7 +195,7 @@ struct tee_shm { unsigned int offset; struct page **pages; size_t num_pages; - struct dma_buf *dmabuf; + refcount_t refcount; u32 flags; int id; }; From 7aedba616cb4be30908dfc62187fa6688c79fdff Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Mon, 20 Dec 2021 11:01:50 -0800 Subject: [PATCH 03/48] UPSTREAM: binder: fix async_free_space accounting for empty parcels commit cfd0d84ba28c18b531648c9d4a35ecca89ad9901 upstream. In 4.13, commit 74310e06be4d ("android: binder: Move buffer out of area shared with user space") fixed a kernel structure visibility issue. As part of that patch, sizeof(void *) was used as the buffer size for 0-length data payloads so the driver could detect abusive clients sending 0-length asynchronous transactions to a server by enforcing limits on async_free_size. Unfortunately, on the "free" side, the accounting of async_free_space did not add the sizeof(void *) back. The result was that up to 8-bytes of async_free_space were leaked on every async transaction of 8-bytes or less. These small transactions are uncommon, so this accounting issue has gone undetected for several years. The fix is to use "buffer_size" (the allocated buffer size) instead of "size" (the logical buffer size) when updating the async_free_space during the free operation. These are the same except for this corner case of asynchronous transactions with payloads < 8 bytes. Fixes: 74310e06be4d ("android: binder: Move buffer out of area shared with user space") Signed-off-by: Todd Kjos Cc: stable@vger.kernel.org # 4.14+ Link: https://lore.kernel.org/r/20211220190150.2107077-1-tkjos@google.com Signed-off-by: Greg Kroah-Hartman Change-Id: Ie01082a056bff56f51035c0f6be34e136bd56faf --- drivers/android/binder_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c index 2739ebbc684b..add45eb9ea97 100644 --- a/drivers/android/binder_alloc.c +++ b/drivers/android/binder_alloc.c @@ -662,7 +662,7 @@ static void binder_free_buf_locked(struct binder_alloc *alloc, BUG_ON(buffer->user_data > alloc->buffer + alloc->buffer_size); if (buffer->async_transaction) { - alloc->free_async_space += size + sizeof(struct binder_buffer); + alloc->free_async_space += buffer_size + sizeof(struct binder_buffer); binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC, "%d: binder_free_buf size %zd async free %zd\n", From fe0c18d0f08da58acf328686a0c78682b54de6b8 Mon Sep 17 00:00:00 2001 From: Tadeusz Struk Date: Wed, 26 Jan 2022 13:09:39 -0800 Subject: [PATCH 04/48] ANDROID: incremental-fs: remove index and incomplete dir on umount Cleanup incremental-fs left overs on umount, otherwise incr-fs will complain as below: BUG: Dentry {i=47a,n=.incomplete} still in use [unmount of incremental-fs] This requires vfs_rmdir() of the special index dir. Since set_anon_super() was used in incfs_mount_fs() the incfs_kill_sb() should use kill_anon_super() instead of generic_shutdown_super() otherwise it will leak the pseudo dev_t that set_anon_super() allocates. Bug: 211066171 Signed-off-by: Tadeusz Struk Change-Id: I7ea54db63513fc130e1997cbf79121015ee12405 --- fs/incfs/vfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/incfs/vfs.c b/fs/incfs/vfs.c index 8d4c4e39fa46..ceb0c2e41402 100644 --- a/fs/incfs/vfs.c +++ b/fs/incfs/vfs.c @@ -2269,7 +2269,7 @@ struct dentry *incfs_mount_fs(struct file_system_type *type, int flags, goto err; } - path_put(&backing_dir_path); + mi->mi_backing_dir_path = backing_dir_path; sb->s_flags |= SB_ACTIVE; pr_debug("incfs: mount\n"); @@ -2309,8 +2309,9 @@ void incfs_kill_sb(struct super_block *sb) struct mount_info *mi = sb->s_fs_info; pr_debug("incfs: unmount\n"); + vfs_rmdir(d_inode(mi->mi_backing_dir_path.dentry), mi->mi_index_dir); + kill_anon_super(sb); incfs_free_mount_info(mi); - generic_shutdown_super(sb); sb->s_fs_info = NULL; } From 4ec7ffac469baf161683aa47a256c6350899855b Mon Sep 17 00:00:00 2001 From: "Eric W. Biederman" Date: Thu, 20 Jan 2022 11:04:01 -0600 Subject: [PATCH 05/48] UPSTREAM: cgroup-v1: Require capabilities to set release_agent The cgroup release_agent is called with call_usermodehelper. The function call_usermodehelper starts the release_agent with a full set fo capabilities. Therefore require capabilities when setting the release_agaent. Reported-by: Tabitha Sable Tested-by: Tabitha Sable Fixes: 81a6a5cdd2c5 ("Task Control Groups: automatic userspace notification of idle cgroups") Cc: stable@vger.kernel.org # v2.6.24+ Signed-off-by: "Eric W. Biederman" Signed-off-by: Tejun Heo (cherry picked from commit 24f6008564183aa120d07c03d9289519c2fe02af) Signed-off-by: Greg Kroah-Hartman Change-Id: If663568d24f781c58c882d69a5b81a9327c0e6fe --- kernel/cgroup/cgroup-v1.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c index b513f70b0cc0..17bf2db821c6 100644 --- a/kernel/cgroup/cgroup-v1.c +++ b/kernel/cgroup/cgroup-v1.c @@ -552,6 +552,14 @@ static ssize_t cgroup_release_agent_write(struct kernfs_open_file *of, BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX); + /* + * Release agent gets called with all capabilities, + * require capabilities to set release agent. + */ + if ((of->file->f_cred->user_ns != &init_user_ns) || + !capable(CAP_SYS_ADMIN)) + return -EPERM; + cgrp = cgroup_kn_lock_live(of->kn, false); if (!cgrp) return -ENODEV; @@ -964,6 +972,12 @@ int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param) /* Specifying two release agents is forbidden */ if (ctx->release_agent) return cg_invalf(fc, "cgroup1: release_agent respecified"); + /* + * Release agent gets called with all capabilities, + * require capabilities to set release agent. + */ + if ((fc->user_ns != &init_user_ns) || !capable(CAP_SYS_ADMIN)) + return cg_invalf(fc, "cgroup1: Setting release_agent not allowed"); ctx->release_agent = param->string; param->string = NULL; break; From 15dd5a8bc02bd6d83d87899c7b6952e058302e88 Mon Sep 17 00:00:00 2001 From: Alistair Delva Date: Mon, 7 Feb 2022 10:30:55 -0800 Subject: [PATCH 06/48] ANDROID: Increase x86 cmdline size to 4k Recently we have started adding more things to kernel command line with the new bootloader able to pass through crosvm built-in cmdline, and on 4.19 this causes problems because all bootconfig keys are also passed as cmdline, exceeding the 2048 byte limit. This causes cmdline truncation which dumps the device in recovery mode. Bump it up until we can turn this testing down. Bug: 217879977 Signed-off-by: Alistair Delva Change-Id: If341f72394de879d43da5206675d21683495d1d0 --- arch/x86/include/asm/setup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h index ed8ec011a9fd..42f3e42a10ee 100644 --- a/arch/x86/include/asm/setup.h +++ b/arch/x86/include/asm/setup.h @@ -4,7 +4,7 @@ #include -#define COMMAND_LINE_SIZE 2048 +#define COMMAND_LINE_SIZE 4096 #include #include From 813b12454e6ef77c5179b5f51cc5f9fed97cce40 Mon Sep 17 00:00:00 2001 From: Amit Pundir Date: Mon, 7 Feb 2022 15:45:29 +0530 Subject: [PATCH 07/48] ANDROID: GKI: db845c: Update symbols list and ABI android11-5.4 is broken on Dragonboard 845c because of recently added symbols. So updating the symbols list by running: BUILD_CONFIG=common/build.config.db845c build/build_abi.sh -s And updated the abi_gki_aarch64 ABI by running: "BUILD_CONFIG=common/build.config.gki.aarch64 \ ABI_DEFINITION=abi_gki_aarch64.xml build/build_abi.sh \ --update --print-report" ======================================================== Leaf changes summary: 1 artifact changed (4 filtered out) Changed leaf types summary: 0 (4 filtered out) leaf types changed Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added function Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable 1 Added function: [A] 'function void kill_anon_super(super_block*)' ======================================================== Bug: 146449535 Signed-off-by: Amit Pundir Change-Id: Ibebf64f3484ed20662487dae0d7db0ef5fac708a --- android/abi_gki_aarch64.xml | 3714 ++++++++++++++++---------------- android/abi_gki_aarch64_db845c | 5 +- 2 files changed, 1877 insertions(+), 1842 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index d9c149005f72..ebc1d68e38dc 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -2365,6 +2365,7 @@ + @@ -6213,12 +6214,12 @@ - + - + - + @@ -6884,12 +6885,12 @@ - + - + - + @@ -19586,109 +19587,109 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -22162,9 +22163,9 @@ - + - + @@ -23718,6 +23719,17 @@ + + + + + + + + + + + @@ -25155,165 +25167,165 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -25932,6 +25944,11 @@ + + + + + @@ -26343,7 +26360,7 @@ - + @@ -26397,7 +26414,7 @@ - + @@ -28617,18 +28634,18 @@ - + - + - + - + - + @@ -31261,7 +31278,7 @@ - + @@ -31269,7 +31286,7 @@ - + @@ -32557,7 +32574,7 @@ - + @@ -32819,7 +32836,7 @@ - + @@ -35859,109 +35876,109 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -37083,6 +37100,14 @@ + + + + + + + + @@ -37877,14 +37902,6 @@ - - - - - - - - @@ -46666,13 +46683,6 @@ - - - - - - - @@ -46773,102 +46783,102 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -46877,7 +46887,7 @@ - + @@ -46901,347 +46911,347 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -47268,63 +47278,63 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -47412,12 +47422,12 @@ - + - + - + @@ -47484,24 +47494,24 @@ - + - + - + - + - + - + - + @@ -48200,22 +48210,22 @@ - - + + - - + + - - + + - - - - + + + + @@ -48224,18 +48234,18 @@ - - + + - - - - + + + + - - + + @@ -48370,7 +48380,7 @@ - + @@ -48789,18 +48799,18 @@ - - + + - - - + + + - - - + + + @@ -48845,42 +48855,42 @@ - - - + + + - - - + + + - - + + - - - + + + - - + + - - - - - + + + + + - - + + @@ -48895,13 +48905,13 @@ - - - + + + - - + + @@ -55450,6 +55460,12 @@ + + + + + + @@ -55831,97 +55847,97 @@ - - + + - - + + - - - - - + + + + + - - - - + + + + - - - - - + + + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - - - - + + + + + - - - + + + - - - + + + - - - + + + - - - + + + @@ -67103,55 +67119,55 @@ - - - + + + - - - - - + + + + + - - - + + + - - - - - + + + + + - - - + + + - - - - + + + + - - - - + + + + - - - + + + - - - + + + @@ -73937,16 +73953,6 @@ - - - - - - - - - - @@ -73960,12 +73966,6 @@ - - - - - - @@ -78188,6 +78188,12 @@ + + + + + + @@ -81841,6 +81847,16 @@ + + + + + + + + + + @@ -85969,11 +85985,11 @@ - + - + @@ -85981,14 +85997,14 @@ - + - + - + @@ -91169,12 +91185,12 @@ - + - + @@ -91183,7 +91199,7 @@ - + @@ -92138,422 +92154,422 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -92573,63 +92589,63 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -92655,59 +92671,59 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -92733,7 +92749,7 @@ - + @@ -92799,13 +92815,13 @@ - + - + @@ -105551,10 +105567,10 @@ - - - - + + + + @@ -107366,8 +107382,8 @@ - - + + @@ -107393,74 +107409,74 @@ - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - - - - - + + + + + - - + + - - + + - - + + - - - + + + @@ -107795,25 +107811,25 @@ - - + + - - + + - - - - + + + + - - - - - + + + + + @@ -108222,8 +108238,8 @@ - - + + @@ -108243,52 +108259,52 @@ - - - - + + + + - + - + - - - - - - + + - - + + - - + + - - + + + + + + - - - + + + @@ -108297,18 +108313,18 @@ - - + + - - - + + + - - - + + + @@ -108318,28 +108334,28 @@ - - - + + + - - - + + + - - - + + + - - - + + + - - + + @@ -108478,7 +108494,7 @@ - + @@ -108541,54 +108557,54 @@ - - + + - - + + - - + + - - - + + + - - - + + + - - + + - - - - - + + + + + - - - - + + + + - - - - + + + + - - - + + + @@ -109234,7 +109250,7 @@ - + @@ -109256,7 +109272,7 @@ - + @@ -109266,7 +109282,7 @@ - + @@ -109274,12 +109290,12 @@ - + - + @@ -109302,7 +109318,7 @@ - + @@ -109318,15 +109334,15 @@ - + - + - + @@ -109337,7 +109353,7 @@ - + @@ -109351,7 +109367,7 @@ - + @@ -109906,7 +109922,7 @@ - + @@ -109983,12 +109999,12 @@ - + - + @@ -110002,11 +110018,6 @@ - - - - - @@ -112435,53 +112446,53 @@ - - + + - - - + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + @@ -112914,165 +112925,165 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -113186,18 +113197,18 @@ - + - + - + - + - + @@ -114635,7 +114646,23 @@ - + + + + + + + + + + + + + + + + + @@ -114823,7 +114850,7 @@ - + @@ -114902,7 +114929,7 @@ - + @@ -114951,7 +114978,7 @@ - + @@ -115242,7 +115269,7 @@ - + @@ -115253,7 +115280,7 @@ - + @@ -115261,7 +115288,7 @@ - + @@ -115711,7 +115738,7 @@ - + @@ -117045,12 +117072,6 @@ - - - - - - @@ -117058,6 +117079,12 @@ + + + + + + @@ -117124,16 +117151,16 @@ - - - - + + + + - - - - + + + + @@ -117489,21 +117516,21 @@ - - + + - - + + - - + + - - - + + + @@ -119181,7 +119208,7 @@ - + @@ -119194,31 +119221,31 @@ - + - + - + - + - - + + - - - - - + + + + + - - + + @@ -119289,24 +119316,24 @@ - + - + - + - + - + - - + + @@ -119325,8 +119352,8 @@ - - + + @@ -119361,85 +119388,85 @@ - - + + - - + + - - - - + + + + - - + + - - - + + + - - - - + + + + - - - - + + + + - - + + - - - + + + - - + + - - - + + + - - + + - - + + - - + + - - - + + + - + - + @@ -119480,7 +119507,7 @@ - + @@ -119495,72 +119522,72 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -119611,44 +119638,44 @@ - - - + + + - + - + - + - + - + - + - - + + - - + + @@ -119657,22 +119684,22 @@ - - + + - - + + - + - + - + @@ -119730,7 +119757,7 @@ - + @@ -120021,17 +120048,17 @@ - - - - + + + + - - - - - + + + + + @@ -124742,9 +124769,9 @@ - - - + + + @@ -126123,12 +126150,12 @@ - - + + - - + + @@ -128948,15 +128975,15 @@ - + - + - + @@ -129104,57 +129131,57 @@ - - + + - - - + + + - - + + - - - - - - + + + + + + - - - - - - - + + + + + + + - - - - - - - - + + + + + + + + - - + + - - + + - - - + + + @@ -130964,38 +130991,38 @@ - - - - - - - + + + + + + + - - - - + + + + - - - - - + + + + + - - - - - - + + + + + + - - + + @@ -136308,8 +136335,8 @@ - - + + @@ -139148,9 +139175,9 @@ - - - + + + @@ -139743,9 +139770,9 @@ - - - + + + @@ -140217,15 +140244,15 @@ - + - + - + - + @@ -140264,7 +140291,7 @@ - + @@ -140274,7 +140301,7 @@ - + @@ -140285,17 +140312,17 @@ - + - + - + @@ -140305,13 +140332,13 @@ - + - + @@ -140322,22 +140349,22 @@ - + - + - + - + @@ -142479,9 +142506,9 @@ - - - + + + @@ -142494,20 +142521,20 @@ - - + + - - + + - - + + - - + + @@ -142518,8 +142545,8 @@ - - + + @@ -144275,28 +144302,28 @@ - - + + - - + + - - + + - - + + - - + + - - + + @@ -144628,9 +144655,9 @@ - - - + + + @@ -147369,6 +147396,10 @@ + + + + @@ -147719,24 +147750,24 @@ - + - + - + - + - + - + - + @@ -147984,18 +148015,18 @@ - + - + - + - + - + @@ -148505,7 +148536,7 @@ - + @@ -148606,6 +148637,12 @@ + + + + + + @@ -148980,6 +149017,13 @@ + + + + + + + @@ -149670,20 +149714,20 @@ - - + + - - + + - - + + - - + + @@ -150813,7 +150857,7 @@ - + @@ -150824,35 +150868,35 @@ - + - + - - + + - - + + - - + + - - - + + + - - - - - - + + + + + + @@ -152753,12 +152797,12 @@ - + - + - + @@ -153706,9 +153750,9 @@ - + - + @@ -162851,22 +162895,22 @@ - - - + + + - - - - + + + + - - - - - + + + + + @@ -162933,19 +162977,19 @@ - - - - + + + + - - - + + + @@ -164174,18 +164218,18 @@ - + - + - + - + - + @@ -164416,7 +164460,7 @@ - + @@ -164640,12 +164684,12 @@ - + - + - + @@ -164700,7 +164744,7 @@ - + @@ -164838,12 +164882,12 @@ - + - + @@ -165101,10 +165145,10 @@ - - - - + + + + @@ -165623,12 +165667,6 @@ - - - - - - @@ -166568,15 +166606,15 @@ - - - - + + + + - - - + + + @@ -166670,12 +166708,6 @@ - - - - - - @@ -166898,209 +166930,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -167236,39 +167068,28 @@ - - - - - - - - - - - - - + + - - - + + + - - - + + + - + @@ -167343,106 +167164,99 @@ - - - - + + + + - - - - + + + + - - + + - - - - + + + + - - + + - - - - + + + + - - + + - - - + + + - - + + - - + + - - - - + + + + - - - - - - + + + + + + - - - + + + - - + + - - - + + + - - + + - - - - + + + + - - - + + + - - - - - - - @@ -167450,10 +167264,6 @@ - - - - @@ -167561,7 +167371,7 @@ - + @@ -167574,8 +167384,8 @@ - - + + @@ -167606,8 +167416,8 @@ - - + + @@ -167787,12 +167597,12 @@ - - + + - - + + @@ -167803,100 +167613,100 @@ - - - - - + + + + + - - - - + + + + - - - - - + + + + + - - - + + + - - - - - + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - + - - - - + + - - - - - - + + + - - - - + + + - - - - - + + + + + + - - - - + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -168973,7 +168783,7 @@ - + @@ -171415,7 +171225,7 @@ - + @@ -171455,7 +171265,7 @@ - + @@ -171537,7 +171347,7 @@ - + @@ -171977,7 +171787,7 @@ - + @@ -173722,7 +173532,7 @@ - + @@ -173742,7 +173552,7 @@ - + @@ -173750,12 +173560,12 @@ - + - + @@ -173886,7 +173696,7 @@ - + @@ -175278,9 +175088,9 @@ - - - + + + @@ -175552,75 +175362,75 @@ - - - + + + - - - + + + - - - - + + + + - - - + + + - - - + + + - - + + - - + + - - - - + + + + - - - - - + + + + + - - - + + + - - - + + + - - - - + + + + - - - - - - + + + + + + @@ -177043,7 +176853,7 @@ - + @@ -177179,7 +176989,7 @@ - + @@ -177722,27 +177532,27 @@ - - - - - + + + + + - - - - - - - + + + + + + + - - - - - + + + + + @@ -178205,13 +178015,224 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -178293,7 +178314,7 @@ - + @@ -178306,6 +178327,17 @@ + + + + + + + + + + + @@ -184196,72 +184228,72 @@ - - - + + + - - - + + + - - - + + + - - - + + + - - - - - + + + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - + + + + + + - - - + + + - - - + + + @@ -190945,16 +190977,16 @@ - - - - + + + + - - - - + + + + @@ -190963,69 +190995,69 @@ - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + diff --git a/android/abi_gki_aarch64_db845c b/android/abi_gki_aarch64_db845c index d9bc40995f5b..898684f65cfe 100644 --- a/android/abi_gki_aarch64_db845c +++ b/android/abi_gki_aarch64_db845c @@ -583,6 +583,7 @@ __kfifo_alloc __kfifo_free kmalloc_order_trace + ktime_get_with_offset __local_bh_enable_ip memmove param_ops_ulong @@ -590,6 +591,7 @@ __rcu_read_lock __rcu_read_unlock regulatory_hint + rfc1042_header skb_copy skb_realloc_headroom strlcat @@ -660,6 +662,7 @@ phy_pm_runtime_get_sync phy_pm_runtime_put_sync platform_get_irq_byname_optional + pm_runtime_barrier system_freezable_wq usb_add_gadget_udc usb_decode_ctrl @@ -733,7 +736,6 @@ generic_file_read_iter generic_file_splice_read generic_read_dir - generic_shutdown_super __get_free_pages get_zeroed_page iget5_locked @@ -745,6 +747,7 @@ kernel_read kernel_write kern_path + kill_anon_super kobject_create_and_add kobject_put lockref_get From 617c7432b539440179d095cba985f1ed70679fb1 Mon Sep 17 00:00:00 2001 From: Alistair Delva Date: Thu, 10 Feb 2022 11:20:10 -0800 Subject: [PATCH 08/48] ANDROID: GKI: Enable CONFIG_SERIAL_8250_RUNTIME_UARTS=0 8250_core registers 4 ISA uart ports by default, which can cause problems on some devices which don't have them. This change doesn't break earlycon=uart8250, but it will cause the 8250_of and 8250_pci sub drivers to be unable to register ports. Boards that really need the full 8250 driver to take over from earlycon can use the "8250.nr_uarts=X" kernel command line option to restore the ports allocation. Bug: 216312411 Signed-off-by: Alistair Delva Change-Id: I04715394b32bd98544657101de4537df34554ea9 [Lee: Fixed merge conflict] Signed-off-by: Lee Jones --- arch/arm64/configs/gki_defconfig | 1 + arch/x86/configs/gki_defconfig | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/arm64/configs/gki_defconfig b/arch/arm64/configs/gki_defconfig index e0a67b0c52f4..67418fc50830 100644 --- a/arch/arm64/configs/gki_defconfig +++ b/arch/arm64/configs/gki_defconfig @@ -317,6 +317,7 @@ CONFIG_SERIAL_8250=y # CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set CONFIG_SERIAL_8250_CONSOLE=y # CONFIG_SERIAL_8250_EXAR is not set +CONFIG_SERIAL_8250_RUNTIME_UARTS=0 CONFIG_SERIAL_OF_PLATFORM=y CONFIG_SERIAL_AMBA_PL011=y CONFIG_SERIAL_AMBA_PL011_CONSOLE=y diff --git a/arch/x86/configs/gki_defconfig b/arch/x86/configs/gki_defconfig index 1da7f7fb4291..f3d46d70e639 100644 --- a/arch/x86/configs/gki_defconfig +++ b/arch/x86/configs/gki_defconfig @@ -289,6 +289,7 @@ CONFIG_INPUT_UINPUT=y CONFIG_SERIAL_8250=y # CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_RUNTIME_UARTS=0 CONFIG_SERIAL_OF_PLATFORM=y CONFIG_SERIAL_DEV_BUS=y CONFIG_HW_RANDOM=y From 717add4ec81bf80af1a091d247d21f3453b9a1ab Mon Sep 17 00:00:00 2001 From: Jon Maloy Date: Sat, 5 Feb 2022 14:11:18 -0500 Subject: [PATCH 09/48] UPSTREAM: tipc: improve size validations for received domain records commit 9aa422ad326634b76309e8ff342c246800621216 upstream. The function tipc_mon_rcv() allows a node to receive and process domain_record structs from peer nodes to track their views of the network topology. This patch verifies that the number of members in a received domain record does not exceed the limit defined by MAX_MON_DOMAIN, something that may otherwise lead to a stack overflow. tipc_mon_rcv() is called from the function tipc_link_proto_rcv(), where we are reading a 32 bit message data length field into a uint16. To avert any risk of bit overflow, we add an extra sanity check for this in that function. We cannot see that happen with the current code, but future designers being unaware of this risk, may introduce it by allowing delivery of very large (> 64k) sk buffers from the bearer layer. This potential problem was identified by Eric Dumazet. This fixes CVE-2022-0435 Reported-by: Samuel Page Reported-by: Eric Dumazet Fixes: 35c55c9877f8 ("tipc: add neighbor monitoring framework") Signed-off-by: Jon Maloy Reviewed-by: Xin Long Reviewed-by: Samuel Page Reviewed-by: Eric Dumazet Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman (cherry picked from commit d692e3406e052dbf9f6d9da0cba36cb763272529) Signed-off-by: Greg Kroah-Hartman Change-Id: I5da5bc6880456ec91e6d3f3a283d2c24b6cc269c --- net/tipc/link.c | 10 +++++++--- net/tipc/monitor.c | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/net/tipc/link.c b/net/tipc/link.c index f25010261a9e..8f2ee71c63c6 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -1953,15 +1953,18 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb, u16 peers_tol = msg_link_tolerance(hdr); u16 peers_prio = msg_linkprio(hdr); u16 rcv_nxt = l->rcv_nxt; - u16 dlen = msg_data_sz(hdr); + u32 dlen = msg_data_sz(hdr), glen = 0; int mtyp = msg_type(hdr); bool reply = msg_probe(hdr); - u16 glen = 0; void *data; char *if_name; int rc = 0; trace_tipc_proto_rcv(skb, false, l->name); + + if (dlen > U16_MAX) + goto exit; + if (tipc_link_is_blocked(l) || !xmitq) goto exit; @@ -2063,7 +2066,8 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb, if (glen != tipc_gap_ack_blks_sz(ga->gack_cnt)) ga = NULL; } - + if(glen > dlen) + break; tipc_mon_rcv(l->net, data + glen, dlen - glen, l->addr, &l->mon_state, l->bearer_id); diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c index 58708b4c7719..e7155a774300 100644 --- a/net/tipc/monitor.c +++ b/net/tipc/monitor.c @@ -457,6 +457,8 @@ void tipc_mon_rcv(struct net *net, void *data, u16 dlen, u32 addr, state->probing = false; /* Sanity check received domain record */ + if (new_member_cnt > MAX_MON_DOMAIN) + return; if (dlen < dom_rec_len(arrv_dom, 0)) return; if (dlen != dom_rec_len(arrv_dom, new_member_cnt)) From f5fe46103f5d4c3d465910f933f64a9f0fd4eabd Mon Sep 17 00:00:00 2001 From: Kalesh Singh Date: Fri, 11 Feb 2022 09:36:26 -0800 Subject: [PATCH 10/48] Revert "tracefs: Have tracefs directories not set OTH permission bits by default" This reverts commit e2c27194fcd9f9703d927aeea104ec304bcf0ae3. This change breaks Android userspace tools (tracepoint bpf programs, simpleperf, atrace, perfetto, ...) that assume access to tracefs. On Android T and S (QPR2) this is fixed by adding a gid mount option in userspace, for devices with older kernels the permission change needs to be reverted. Bug: 217150407 Bug: 216676030 Signed-off-by: Kalesh Singh Change-Id: I53a63c42b4cf1133a6a2fc1674380ffd8f331392 --- fs/tracefs/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index efe078fe5d4a..0caa151cae4e 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -427,8 +427,7 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent, if (unlikely(!inode)) return failed_creating(dentry); - /* Do not set bits for OTH */ - inode->i_mode = S_IFDIR | S_IRWXU | S_IRUSR| S_IRGRP | S_IXUSR | S_IXGRP; + inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO; inode->i_op = ops; inode->i_fop = &simple_dir_operations; From 0d1f1d4375c98f5fa33277cd3f1be90949445c12 Mon Sep 17 00:00:00 2001 From: Szymon Heidrich Date: Mon, 24 Jan 2022 12:14:00 +0100 Subject: [PATCH 11/48] UPSTREAM: USB: gadget: validate interface OS descriptor requests Stall the control endpoint in case provided index exceeds array size of MAX_CONFIG_INTERFACES or when the retrieved function pointer is null. Bug: 213172319 Signed-off-by: Szymon Heidrich Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 75e5b4849b81e19e9efe1654b30d7f3151c33c2c) Signed-off-by: Greg Kroah-Hartman Change-Id: I78f46b6f2140394a6bc6cff9f829c0742d7ad2fc --- drivers/usb/gadget/composite.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index c5acf5c39fb1..a3106b179562 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1944,6 +1944,9 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) if (w_index != 0x5 || (w_value >> 8)) break; interface = w_value & 0xFF; + if (interface >= MAX_CONFIG_INTERFACES || + !os_desc_cfg->interface[interface]) + break; buf[6] = w_index; count = count_ext_prop(os_desc_cfg, interface); From 9a4b39bd766255179c8fce534c7e1e4036900969 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 9 Feb 2022 16:37:53 +0100 Subject: [PATCH 12/48] UPSTREAM: usb: gadget: rndis: check size of RNDIS_MSG_SET command Check the size of the RNDIS_MSG_SET command given to us before attempting to respond to an invalid message size. Bug: 162326603 Reported-by: Szymon Heidrich Cc: stable@kernel.org Tested-by: Szymon Heidrich Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 38ea1eac7d88072bbffb630e2b3db83ca649b826) Signed-off-by: Greg Kroah-Hartman Change-Id: I61168b48de4ca79a3a28dd4d3b81779bc25554c1 --- drivers/usb/gadget/function/rndis.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c index 04c142c13075..ab827c1badc5 100644 --- a/drivers/usb/gadget/function/rndis.c +++ b/drivers/usb/gadget/function/rndis.c @@ -637,14 +637,17 @@ static int rndis_set_response(struct rndis_params *params, rndis_set_cmplt_type *resp; rndis_resp_t *r; + BufLength = le32_to_cpu(buf->InformationBufferLength); + BufOffset = le32_to_cpu(buf->InformationBufferOffset); + if ((BufLength > RNDIS_MAX_TOTAL_SIZE) || + (BufOffset + 8 >= RNDIS_MAX_TOTAL_SIZE)) + return -EINVAL; + r = rndis_add_response(params, sizeof(rndis_set_cmplt_type)); if (!r) return -ENOMEM; resp = (rndis_set_cmplt_type *)r->buf; - BufLength = le32_to_cpu(buf->InformationBufferLength); - BufOffset = le32_to_cpu(buf->InformationBufferOffset); - #ifdef VERBOSE_DEBUG pr_debug("%s: Length: %d\n", __func__, BufLength); pr_debug("%s: Offset: %d\n", __func__, BufOffset); From 46778c889eb692508868e85da1f4e26eae444be4 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Thu, 9 Dec 2021 10:25:43 -0800 Subject: [PATCH 13/48] FROMGIT: f2fs: avoid EINVAL by SBI_NEED_FSCK when pinning a file Android OTA failed due to SBI_NEED_FSCK flag when pinning the file. Let's avoid it since we can do in-place-updates. Bug: 210593661 Signed-off-by: Jaegeuk Kim (cherry picked from commit 70da2736a4138b86a12873d33fefbb495e22e6f8 git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev) Signed-off-by: Huang Jianan Change-Id: I3fd33c984417c10b38e23de6cec017b03d588945 Signed-off-by: David Anderson --- fs/f2fs/data.c | 5 +++++ fs/f2fs/file.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 70cf1a7560e1..73beaaf397bf 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2577,6 +2577,11 @@ bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio) { struct f2fs_sb_info *sbi = F2FS_I_SB(inode); + /* The below cases were checked when setting it. */ + if (f2fs_is_pinned_file(inode)) + return false; + if (fio && is_sbi_flag_set(sbi, SBI_NEED_FSCK)) + return true; if (f2fs_lfs_mode(sbi)) return true; if (S_ISDIR(inode->i_mode)) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index a6fc4445ccdd..b42b1fa737bd 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3235,17 +3235,17 @@ static int f2fs_ioc_set_pin_file(struct file *filp, unsigned long arg) inode_lock(inode); - if (f2fs_should_update_outplace(inode, NULL)) { - ret = -EINVAL; - goto out; - } - if (!pin) { clear_inode_flag(inode, FI_PIN_FILE); f2fs_i_gc_failures_write(inode, 0); goto done; } + if (f2fs_should_update_outplace(inode, NULL)) { + ret = -EINVAL; + goto out; + } + if (f2fs_pin_file_control(inode, false)) { ret = -EAGAIN; goto out; From 11642ca31e9ef7ee318bb3d4bb5e2bd435e879c0 Mon Sep 17 00:00:00 2001 From: Ashish Chavan Date: Sun, 20 Feb 2022 14:44:17 +0530 Subject: [PATCH 14/48] power: supply: smb5: Fix moisture detection exit condition When USB is connected and moisture detected we disable USB_ICL with LPD_VOTER. This voter is not removed until usb is removed. Fix this by removing LPD_VOTER vote from ICL when LPD bit is not set with usb connected. Change-Id: I188f5d94bc3ec3527ddccf116a6a68a4b9ddea6d Signed-off-by: Ashish Chavan --- drivers/power/supply/qcom/smb5-lib.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/qcom/smb5-lib.c b/drivers/power/supply/qcom/smb5-lib.c index ce4ba0aaffab..4bfead753772 100644 --- a/drivers/power/supply/qcom/smb5-lib.c +++ b/drivers/power/supply/qcom/smb5-lib.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2022 The Linux Foundation. All rights reserved. */ #include @@ -8047,6 +8047,9 @@ static void smblib_lpd_ra_open_work(struct work_struct *work) if (!(stat & TYPEC_WATER_DETECTION_STATUS_BIT) || (stat & TYPEC_TCCDEBOUNCE_DONE_STATUS_BIT)) { chg->lpd_stage = LPD_STAGE_NONE; + + /* Remove LPD_VOTER from ICL is moisture status is gone in attached state. */ + vote(chg->usb_icl_votable, LPD_VOTER, false, 0); goto out; } From 2b144ea90c6cb062689b4c05be9a4c53e2f49167 Mon Sep 17 00:00:00 2001 From: Howard Chen Date: Wed, 23 Feb 2022 15:00:13 +0800 Subject: [PATCH 15/48] Revert "ANDROID: incremental-fs: fix mount_fs issue" This reverts commit 013b7ed7546e04b50abdb26dee92114e43c3064f. Test: Can now install the same apk twice, and repeated installs are stable Bug: 217661925 Bug: 219731048 Signed-off-by: Paul Lawrence Change-Id: I86871c364c17a0d1107b3891a574b72edcf04ea2 (cherry picked from commit d107cd06f26b4d45b1079c7eb857815905198076) Signed-off-by: Howard Chen --- fs/incfs/vfs.c | 58 ++++++++++++++------------------------------------ 1 file changed, 16 insertions(+), 42 deletions(-) diff --git a/fs/incfs/vfs.c b/fs/incfs/vfs.c index ceb0c2e41402..62425969c75b 100644 --- a/fs/incfs/vfs.c +++ b/fs/incfs/vfs.c @@ -319,6 +319,7 @@ static struct mount_info *get_mount_info(struct super_block *sb) { struct mount_info *result = sb->s_fs_info; + WARN_ON(!result); return result; } @@ -677,7 +678,7 @@ static int iterate_incfs_dir(struct file *file, struct dir_context *ctx) struct mount_info *mi = get_mount_info(file_superblock(file)); bool root; - if (!dir || !mi) { + if (!dir) { error = -EBADF; goto out; } @@ -1841,9 +1842,6 @@ static int dir_rename(struct inode *old_dir, struct dentry *old_dentry, struct dentry *trap; int error = 0; - if (!mi) - return -EBADF; - error = mutex_lock_interruptible(&mi->mi_dir_struct_mutex); if (error) return error; @@ -2091,9 +2089,6 @@ static ssize_t incfs_getxattr(struct dentry *d, const char *name, char *stored_value; size_t stored_size; - if (!mi) - return -EBADF; - if (di && di->backing_path.dentry) return vfs_getxattr(di->backing_path.dentry, name, value, size); @@ -2130,9 +2125,6 @@ static ssize_t incfs_setxattr(struct dentry *d, const char *name, void **stored_value; size_t *stored_size; - if (!mi) - return -EBADF; - if (di && di->backing_path.dentry) return vfs_setxattr(di->backing_path.dentry, name, value, size, flags); @@ -2173,11 +2165,6 @@ static ssize_t incfs_listxattr(struct dentry *d, char *list, size_t size) return vfs_listxattr(di->backing_path.dentry, list, size); } -static int incfs_test_super(struct super_block *s, void *p) -{ - return s->s_fs_info != NULL; -} - struct dentry *incfs_mount_fs(struct file_system_type *type, int flags, const char *dev_name, void *data) { @@ -2187,8 +2174,7 @@ struct dentry *incfs_mount_fs(struct file_system_type *type, int flags, struct dentry *index_dir; struct super_block *src_fs_sb = NULL; struct inode *root_inode = NULL; - struct super_block *sb = sget(type, incfs_test_super, set_anon_super, - flags, NULL); + struct super_block *sb = sget(type, NULL, set_anon_super, flags, NULL); int error = 0; if (IS_ERR(sb)) @@ -2229,18 +2215,13 @@ struct dentry *incfs_mount_fs(struct file_system_type *type, int flags, src_fs_sb = backing_dir_path.dentry->d_sb; sb->s_maxbytes = src_fs_sb->s_maxbytes; - if (!sb->s_fs_info) { - mi = incfs_alloc_mount_info(sb, &options, &backing_dir_path); + mi = incfs_alloc_mount_info(sb, &options, &backing_dir_path); - if (IS_ERR_OR_NULL(mi)) { - error = PTR_ERR(mi); - pr_err("incfs: Error allocating mount info. %d\n", error); - mi = NULL; - goto err; - } - sb->s_fs_info = mi; - } else { - mi = sb->s_fs_info; + if (IS_ERR_OR_NULL(mi)) { + error = PTR_ERR(mi); + pr_err("incfs: Error allocating mount info. %d\n", error); + mi = NULL; + goto err; } index_dir = open_or_create_index_dir(backing_dir_path.dentry); @@ -2252,22 +2233,21 @@ struct dentry *incfs_mount_fs(struct file_system_type *type, int flags, } mi->mi_index_dir = index_dir; + sb->s_fs_info = mi; root_inode = fetch_regular_inode(sb, backing_dir_path.dentry); if (IS_ERR(root_inode)) { error = PTR_ERR(root_inode); goto err; } + sb->s_root = d_make_root(root_inode); if (!sb->s_root) { - sb->s_root = d_make_root(root_inode); - if (!sb->s_root) { - error = -ENOMEM; - goto err; - } - error = incfs_init_dentry(sb->s_root, &backing_dir_path); - if (error) - goto err; + error = -ENOMEM; + goto err; } + error = incfs_init_dentry(sb->s_root, &backing_dir_path); + if (error) + goto err; mi->mi_backing_dir_path = backing_dir_path; sb->s_flags |= SB_ACTIVE; @@ -2288,9 +2268,6 @@ static int incfs_remount_fs(struct super_block *sb, int *flags, char *data) struct mount_info *mi = get_mount_info(sb); int err = 0; - if (!mi) - return err; - sync_filesystem(sb); err = parse_options(&options, (char *)data); if (err) @@ -2319,9 +2296,6 @@ static int show_options(struct seq_file *m, struct dentry *root) { struct mount_info *mi = get_mount_info(root->d_sb); - if (!mi) - return -EBADF; - seq_printf(m, ",read_timeout_ms=%u", mi->mi_options.read_timeout_ms); seq_printf(m, ",readahead=%u", mi->mi_options.readahead_pages); if (mi->mi_options.read_log_pages != 0) { From 88e13027695dd46ebe49db8a1c70504a8cafa084 Mon Sep 17 00:00:00 2001 From: Tadeusz Struk Date: Wed, 23 Feb 2022 09:47:03 -0800 Subject: [PATCH 16/48] Revert "ANDROID: incremental-fs: remove index and incomplete dir on umount" This reverts commit fe0c18d0f08da58acf328686a0c78682b54de6b8. This is follow up cleanup after revert of: "Revert "ANDROID: incremental-fs: fix mount_fs issue" Bug: 220805927 Signed-off-by: Tadeusz Struk Change-Id: I7749401484d87b9d519bd7b9600cd02f91a18090 --- fs/incfs/vfs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/incfs/vfs.c b/fs/incfs/vfs.c index 62425969c75b..b849568ae9b8 100644 --- a/fs/incfs/vfs.c +++ b/fs/incfs/vfs.c @@ -2249,7 +2249,7 @@ struct dentry *incfs_mount_fs(struct file_system_type *type, int flags, if (error) goto err; - mi->mi_backing_dir_path = backing_dir_path; + path_put(&backing_dir_path); sb->s_flags |= SB_ACTIVE; pr_debug("incfs: mount\n"); @@ -2286,9 +2286,8 @@ void incfs_kill_sb(struct super_block *sb) struct mount_info *mi = sb->s_fs_info; pr_debug("incfs: unmount\n"); - vfs_rmdir(d_inode(mi->mi_backing_dir_path.dentry), mi->mi_index_dir); - kill_anon_super(sb); incfs_free_mount_info(mi); + generic_shutdown_super(sb); sb->s_fs_info = NULL; } From 5d7a491ae4a76ffe84bc76c16383ffedc69b5826 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 21 Feb 2022 11:03:13 +0100 Subject: [PATCH 17/48] UPSTREAM: lib/iov_iter: initialize "flags" in new pipe_buffer commit 9d2231c5d74e13b2a0546fee6737ee4446017903 upstream. The functions copy_page_to_iter_pipe() and push_pipe() can both allocate a new pipe_buffer, but the "flags" member initializer is missing. Fixes: 241699cd72a8 ("new iov_iter flavour: pipe-backed") To: Alexander Viro To: linux-fsdevel@vger.kernel.org To: linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org Signed-off-by: Max Kellermann Signed-off-by: Al Viro Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 87c575d2a238febe8a04241008f18252fe5d093d) Bug: 220741611 Signed-off-by: Greg Kroah-Hartman Change-Id: I91076a0b6327ee8dd87e75fc875062b6adf2de4c --- lib/iov_iter.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 957e3e58df65..9d3bda3d49fe 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -398,6 +398,7 @@ static size_t copy_page_to_iter_pipe(struct page *page, size_t offset, size_t by return 0; pipe->nrbufs++; buf->ops = &page_cache_pipe_buf_ops; + buf->flags = 0; get_page(buf->page = page); buf->offset = offset; buf->len = bytes; @@ -524,6 +525,7 @@ static size_t push_pipe(struct iov_iter *i, size_t size, break; pipe->nrbufs++; pipe->bufs[idx].ops = &default_pipe_buf_ops; + pipe->bufs[idx].flags = 0; pipe->bufs[idx].page = page; pipe->bufs[idx].offset = 0; if (left <= PAGE_SIZE) { From d5a7ee66e0241248b240d1d1afbdacfaa1310832 Mon Sep 17 00:00:00 2001 From: Sai Chaitanya Kaveti Date: Fri, 25 Feb 2022 16:37:17 +0530 Subject: [PATCH 18/48] msm: mhi_dev: Changing the GFP flag in alloc_skb() GFP_ATOMIC flag is typically used in memory allocations inside interrupt handlers or with spin locks. It is of high priority but it does not allow the caller to reclaim the memory allocation request. This may lead to memory allocation failures in low memory situations. Since alloc_skb() is not called from interrupt handler or in spin lock context, changing the GFP flag from GFP_ATOMIC to GFP_KERNEL. Change-Id: I6c3a2b5b4674965cf1d4860e9072fa46cd4adddb Signed-off-by: Sai Chaitanya Kaveti --- drivers/platform/msm/mhi_dev/mhi_dev_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/msm/mhi_dev/mhi_dev_net.c b/drivers/platform/msm/mhi_dev/mhi_dev_net.c index 08bf7f995f8f..c4b9d6972e33 100644 --- a/drivers/platform/msm/mhi_dev/mhi_dev_net.c +++ b/drivers/platform/msm/mhi_dev/mhi_dev_net.c @@ -279,7 +279,7 @@ static ssize_t mhi_dev_net_client_read(struct mhi_dev_net_client *mhi_handle) struct mhi_req, list); list_del_init(&req->list); spin_unlock_irqrestore(&mhi_handle->rd_lock, flags); - skb = alloc_skb(MHI_NET_DEFAULT_MTU, GFP_ATOMIC); + skb = alloc_skb(MHI_NET_DEFAULT_MTU, GFP_KERNEL); if (skb == NULL) { pr_err("%s(): skb alloc failed\n", __func__); spin_lock_irqsave(&mhi_handle->rd_lock, flags); From cfa75093c007e04daecd6de59f70ea032185ab50 Mon Sep 17 00:00:00 2001 From: Liron Daniel Date: Wed, 22 Apr 2020 00:26:37 +0300 Subject: [PATCH 19/48] soc: qcom: spcom: Pass channel name as formatted string to device_create Pass channel name as formmated string to device_create call in spcom_create_channel_chardevto prevent memory access issues when using formatted string as channel name. Change-Id: I549087a49e97f0b1a66ea5816eabfe80a6f7f1f7 Signed-off-by: Liron Daniel --- drivers/soc/qcom/spcom.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/soc/qcom/spcom.c b/drivers/soc/qcom/spcom.c index 1016843ca039..a966ba98c30a 100644 --- a/drivers/soc/qcom/spcom.c +++ b/drivers/soc/qcom/spcom.c @@ -621,7 +621,6 @@ static int spcom_handle_create_channel_command(void *cmd_buf, int cmd_size) { int ret = 0; struct spcom_user_create_channel_command *cmd = cmd_buf; - const size_t maxlen = sizeof(cmd->ch_name); if (cmd_size != sizeof(*cmd)) { spcom_pr_err("cmd_size [%d] , expected [%d]\n", @@ -629,11 +628,6 @@ static int spcom_handle_create_channel_command(void *cmd_buf, int cmd_size) return -EINVAL; } - if (strnlen(cmd->ch_name, maxlen) == maxlen) { - spcom_pr_err("channel name is not NULL terminated\n"); - return -EINVAL; - } - mutex_lock(&spcom_dev->chdev_count_lock); ret = spcom_create_channel_chardev(cmd->ch_name, cmd->is_sharable); mutex_unlock(&spcom_dev->chdev_count_lock); @@ -2003,6 +1997,12 @@ static int spcom_create_channel_chardev(const char *name, bool is_sharable) void *priv; struct cdev *cdev; + if (!name || strnlen(name, SPCOM_CHANNEL_NAME_SIZE) == + SPCOM_CHANNEL_NAME_SIZE) { + spcom_pr_err("invalid channel name\n"); + return -EINVAL; + } + spcom_pr_dbg("creating channel [%s]\n", name); ch = spcom_find_channel_by_name(name); @@ -2037,7 +2037,12 @@ static int spcom_create_channel_chardev(const char *name, bool is_sharable) devt = spcom_dev->device_no + spcom_dev->chdev_count; priv = ch; - dev = device_create(cls, parent, devt, priv, name); + + /* + * Pass channel name as formatted string to avoid abuse by using a + * formatted string as channel name + */ + dev = device_create(cls, parent, devt, priv, "%s", name); if (IS_ERR(dev)) { spcom_pr_err("device_create failed\n"); ret = -ENODEV; From 570071dcd1f1d6d3ddf1ee11f63ddfed64af56d6 Mon Sep 17 00:00:00 2001 From: Srinivasarao Pathipati Date: Fri, 4 Mar 2022 14:06:19 +0530 Subject: [PATCH 20/48] arm64: defconfig: cleanup the holi_GKI.config Cleanup the redundant configs from holi_GKI.config as they are updated in gki_defconfig. Change-Id: I9e1a3bc7800e9d1e56ba651a63ebab03dd52546e Signed-off-by: Srinivasarao Pathipati --- arch/arm64/configs/vendor/holi_GKI.config | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arch/arm64/configs/vendor/holi_GKI.config b/arch/arm64/configs/vendor/holi_GKI.config index 8583022f8f88..031730e79137 100644 --- a/arch/arm64/configs/vendor/holi_GKI.config +++ b/arch/arm64/configs/vendor/holi_GKI.config @@ -9,7 +9,6 @@ CONFIG_QCOM_COMMAND_DB=m CONFIG_PINCTRL_HOLI=m CONFIG_REGULATOR_STUB=m CONFIG_REGULATOR_PROXY_CONSUMER=m -CONFIG_KEYBOARD_GPIO=m CONFIG_EXTCON=m CONFIG_SPMI_MSM_PMIC_ARB=m CONFIG_SPMI_MSM_PMIC_ARB_DEBUG=m @@ -52,7 +51,6 @@ CONFIG_QCOM_SMP2P=m CONFIG_QCOM_SMSM=m CONFIG_MSM_QMP=m CONFIG_QCOM_SMP2P_SLEEPSTATE=m -CONFIG_RPMSG_CHAR=m CONFIG_RPMSG_QCOM_GLINK_RPM=m CONFIG_RPMSG_QCOM_GLINK_SMEM=m CONFIG_QCOM_GLINK=m @@ -72,7 +70,6 @@ CONFIG_MSM_SERVICE_LOCATOR=m CONFIG_MSM_SERVICE_NOTIFIER=m CONFIG_QSEE_IPC_IRQ=m CONFIG_RPMSG_QCOM_GLINK_SPSS=m -CONFIG_REGULATOR_FIXED_VOLTAGE=m CONFIG_REGULATOR_QTI_FIXED_VOLTAGE=m CONFIG_REGULATOR_REFGEN=m CONFIG_COMMON_CLK_QCOM=m @@ -186,15 +183,11 @@ CONFIG_SND_USB_AUDIO_QMI=m # CONFIG_USB_STORAGE_KARMA is not set # CONFIG_USB_STORAGE_CYPRESS_ATACB is not set # CONFIG_USB_STORAGE_ENE_UB6250 is not set -# CONFIG_USB_UAS is not set -CONFIG_USB_STORAGE=m -CONFIG_USB_CONFIGFS_NCM=m CONFIG_USB_CONFIGFS_F_CCID=m CONFIG_USB_CONFIGFS_F_CDEV=m CONFIG_USB_CONFIGFS_F_GSI=m CONFIG_MSM_QUSB_PHY=m CONFIG_MEDIA_USB_SUPPORT=y -CONFIG_USB_VIDEO_CLASS=m CONFIG_LEDS_QPNP_FLASH_V2=m CONFIG_QTI_IOMMU_SUPPORT=m CONFIG_MMC_SDHCI_MSM=m From 3ec6ac1cd289905503fcc8f580f17de29a6930e8 Mon Sep 17 00:00:00 2001 From: "taehyun.cho" Date: Thu, 15 Oct 2020 23:13:20 -0700 Subject: [PATCH 21/48] ANDROID: USB: gadget: f_accessory: add support for SuperSpeed Plus Adds the necessary SuperSpeed Plus support for f_accessory. [Not upstream as this file is not upstream]. Bug: 170925797 Signed-off-by: taehyun.cho Change-Id: Ia2a5f4a6cefac2418f8f29bf1a56355b96d80fc0 (cherry picked from commit 00572be28ec474d7953f1b9dd681cc2dd290d9bf) [willmcvicker: only cherry-pick f_accessory from original patch] Signed-off-by: Will McVicker (cherry picked from commit 4d7ced0819d3f30acbde46991393249049cefa05) Signed-off-by: Will McVicker Signed-off-by: Greg Kroah-Hartman Git-commit: 9acdbad022c88c958ba69ab3f021f2e8a07cfc45 Git-Repo: https://android.googlesource.com/kernel/common/ Signed-off-by: Pratham Pratap --- drivers/usb/gadget/function/f_accessory.c | 75 ++++++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/f_accessory.c b/drivers/usb/gadget/function/f_accessory.c index 2d2ebbb41a38..82b2cf491e70 100644 --- a/drivers/usb/gadget/function/f_accessory.c +++ b/drivers/usb/gadget/function/f_accessory.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Gadget Function Driver for Android USB accessories * @@ -142,12 +143,62 @@ static struct usb_interface_descriptor acc_interface_desc = { .bInterfaceProtocol = 0, }; +static struct usb_endpoint_descriptor acc_superspeedplus_in_desc = { + .bLength = USB_DT_ENDPOINT_SIZE, + .bDescriptorType = USB_DT_ENDPOINT, + .bEndpointAddress = USB_DIR_IN, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = cpu_to_le16(1024), +}; + +static struct usb_endpoint_descriptor acc_superspeedplus_out_desc = { + .bLength = USB_DT_ENDPOINT_SIZE, + .bDescriptorType = USB_DT_ENDPOINT, + .bEndpointAddress = USB_DIR_OUT, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = cpu_to_le16(1024), +}; + +static struct usb_ss_ep_comp_descriptor acc_superspeedplus_comp_desc = { + .bLength = sizeof(acc_superspeedplus_comp_desc), + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, + + /* the following 2 values can be tweaked if necessary */ + /* .bMaxBurst = 0, */ + /* .bmAttributes = 0, */ +}; + +static struct usb_endpoint_descriptor acc_superspeed_in_desc = { + .bLength = USB_DT_ENDPOINT_SIZE, + .bDescriptorType = USB_DT_ENDPOINT, + .bEndpointAddress = USB_DIR_IN, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = cpu_to_le16(1024), +}; + +static struct usb_endpoint_descriptor acc_superspeed_out_desc = { + .bLength = USB_DT_ENDPOINT_SIZE, + .bDescriptorType = USB_DT_ENDPOINT, + .bEndpointAddress = USB_DIR_OUT, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = cpu_to_le16(1024), +}; + +static struct usb_ss_ep_comp_descriptor acc_superspeed_comp_desc = { + .bLength = sizeof(acc_superspeed_comp_desc), + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, + + /* the following 2 values can be tweaked if necessary */ + /* .bMaxBurst = 0, */ + /* .bmAttributes = 0, */ +}; + static struct usb_endpoint_descriptor acc_highspeed_in_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_endpoint_descriptor acc_highspeed_out_desc = { @@ -155,7 +206,7 @@ static struct usb_endpoint_descriptor acc_highspeed_out_desc = { .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_OUT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_endpoint_descriptor acc_fullspeed_in_desc = { @@ -186,6 +237,24 @@ static struct usb_descriptor_header *hs_acc_descs[] = { NULL, }; +static struct usb_descriptor_header *ss_acc_descs[] = { + (struct usb_descriptor_header *) &acc_interface_desc, + (struct usb_descriptor_header *) &acc_superspeed_in_desc, + (struct usb_descriptor_header *) &acc_superspeed_comp_desc, + (struct usb_descriptor_header *) &acc_superspeed_out_desc, + (struct usb_descriptor_header *) &acc_superspeed_comp_desc, + NULL, +}; + +static struct usb_descriptor_header *ssp_acc_descs[] = { + (struct usb_descriptor_header *) &acc_interface_desc, + (struct usb_descriptor_header *) &acc_superspeedplus_in_desc, + (struct usb_descriptor_header *) &acc_superspeedplus_comp_desc, + (struct usb_descriptor_header *) &acc_superspeedplus_out_desc, + (struct usb_descriptor_header *) &acc_superspeedplus_comp_desc, + NULL, +}; + static struct usb_string acc_string_defs[] = { [INTERFACE_STRING_INDEX].s = "Android Accessory Interface", { }, /* end of list */ @@ -1435,6 +1504,8 @@ static struct usb_function *acc_alloc(struct usb_function_instance *fi) dev->function.strings = acc_strings, dev->function.fs_descriptors = fs_acc_descs; dev->function.hs_descriptors = hs_acc_descs; + dev->function.ss_descriptors = ss_acc_descs; + dev->function.ssp_descriptors = ssp_acc_descs; dev->function.bind = acc_function_bind_configfs; dev->function.unbind = acc_function_unbind; dev->function.set_alt = acc_function_set_alt; From fb338f982c1d9331ca3ec4896c111586f78f38f2 Mon Sep 17 00:00:00 2001 From: Ray Chi Date: Thu, 13 May 2021 13:47:45 +0800 Subject: [PATCH 22/48] ANDROID: usb: gadget: f_accessory: update SS/SSP descriptors Currently, only HS descriptors will be updated with endpoint address during binding process. According to current max_speed in configfs, this patch will also update SS/SSP descriptors with endpoint address. Bug: 162562782 Signed-off-by: Ray Chi Change-Id: I67983ef47df7ac567ec1d3af80921c39c98a545d Git-commit: 41fe558317e9ffdc07326e8ef9ca6ea596d9a518 Git-Repo: https://android.googlesource.com/kernel/common/ Signed-off-by: Pratham Pratap --- drivers/usb/gadget/function/f_accessory.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/function/f_accessory.c b/drivers/usb/gadget/function/f_accessory.c index 82b2cf491e70..de873380f7d1 100644 --- a/drivers/usb/gadget/function/f_accessory.c +++ b/drivers/usb/gadget/function/f_accessory.c @@ -1116,12 +1116,22 @@ __acc_function_bind(struct usb_configuration *c, return ret; /* support high speed hardware */ - if (gadget_is_dualspeed(c->cdev->gadget)) { - acc_highspeed_in_desc.bEndpointAddress = - acc_fullspeed_in_desc.bEndpointAddress; - acc_highspeed_out_desc.bEndpointAddress = - acc_fullspeed_out_desc.bEndpointAddress; - } + acc_highspeed_in_desc.bEndpointAddress = + acc_fullspeed_in_desc.bEndpointAddress; + acc_highspeed_out_desc.bEndpointAddress = + acc_fullspeed_out_desc.bEndpointAddress; + + /* support super speed hardware */ + acc_superspeed_in_desc.bEndpointAddress = + acc_fullspeed_in_desc.bEndpointAddress; + acc_superspeed_out_desc.bEndpointAddress = + acc_fullspeed_out_desc.bEndpointAddress; + + /* support super speed plus hardware */ + acc_superspeedplus_in_desc.bEndpointAddress = + acc_fullspeed_in_desc.bEndpointAddress; + acc_superspeedplus_out_desc.bEndpointAddress = + acc_fullspeed_out_desc.bEndpointAddress; DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n", gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", From c1b9e196cbba4465498b34c1fc60db0f01c1888b Mon Sep 17 00:00:00 2001 From: Jilai Wang Date: Sun, 27 Feb 2022 22:42:48 -0500 Subject: [PATCH 23/48] msm: npu: Avoid buffer overflow when handling get_property packet If packet size is set to invalid value by firmware, when driver tries to copy property content to memory, it could cause buffer overflow. To avoid this, packet size needs to be checked to make sure it's valid. Change-Id: Ic549f840db998385323e89b3f3dbe2e4349b932e Signed-off-by: Jilai Wang --- drivers/media/platform/msm/npu/npu_mgr.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/platform/msm/npu/npu_mgr.c b/drivers/media/platform/msm/npu/npu_mgr.c index ca3a37288e57..f36aff27ccc5 100644 --- a/drivers/media/platform/msm/npu/npu_mgr.c +++ b/drivers/media/platform/msm/npu/npu_mgr.c @@ -911,6 +911,13 @@ static void app_msg_proc(struct npu_host_ctx *host_ctx, uint32_t *msg) prop_rsp_pkt->num_params, prop_rsp_pkt->prop_param[0]); + if (prop_rsp_pkt->header.size < + sizeof(struct ipc_msg_header_pkt)) { + pr_err("Invalid rsp pkt size %d\n", + prop_rsp_pkt->header.size); + break; + } + host_ctx->cmd_ret_status = prop_rsp_pkt->header.status; if (prop_rsp_pkt->num_params > 0) { From 080a6e25a36bd975a17fa51d39e73d9942d80fe5 Mon Sep 17 00:00:00 2001 From: Ajay Agarwal Date: Wed, 5 Jan 2022 12:38:49 +0530 Subject: [PATCH 24/48] usb: dwc3: Disable USB2 internal retry for USB3.1 cores v1.70a and above STAR 9001346572 affects dwc_usb3.1 versions 1.70a and above. Disable USB2 internal retry for the same. Change-Id: Id476220130518c0fd740d9be5d6db1e712529112 Signed-off-by: Ajay Agarwal Signed-off-by: Udipto Goswami --- drivers/usb/dwc3/core.c | 18 +++++++++++++++++- drivers/usb/dwc3/core.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 3e4738bbe488..1d063c35b5fe 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1157,11 +1157,27 @@ int dwc3_core_init(struct dwc3 *dwc) dwc3_writel(dwc->regs, DWC31_LCSR_TX_DEEMPH_3(0), dwc->gen2_tx_de_emph3 & DWC31_TX_DEEMPH_MASK); - /* set inter-packet gap 199.794ns to improve EL_23 margin */ + /* + * Set inter-packet gap 199.794ns to improve EL_23 margin. + * + * STAR 9001346572: Host: When a Single USB 2.0 Endpoint Receives NAKs Continuously, Host + * Stops Transfers to Other Endpoints. When an active endpoint that is not currently cached + * in the host controller is chosen to be cached to the same cache index as the endpoint + * that receives NAK, The endpoint that receives the NAK responses would be in continuous + * retry mode that would prevent it from getting evicted out of the host controller cache. + * This would prevent the new endpoint to get into the endpoint cache and therefore service + * to this endpoint is not done. + * The workaround is to disable lower layer LSP retrying the USB2.0 NAKed transfer. Forcing + * this to LSP upper layer allows next EP to evict the stuck EP from cache. + */ if (dwc->revision >= DWC3_USB31_REVISION_170A) { reg = dwc3_readl(dwc->regs, DWC3_GUCTL1); reg |= DWC3_GUCTL1_IP_GAP_ADD_ON(1); dwc3_writel(dwc->regs, DWC3_GUCTL1, reg); + + reg = dwc3_readl(dwc->regs, DWC3_GUCTL3); + reg |= DWC3_GUCTL3_USB20_RETRY_DISABLE; + dwc3_writel(dwc->regs, DWC3_GUCTL3, reg); } return 0; diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 3bd15568f1ab..a796ed1bbe91 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -413,6 +413,7 @@ #define DWC3_GUCTL2_RST_ACTBITLATER BIT(14) /* Global User Control Register 3 */ +#define DWC3_GUCTL3_USB20_RETRY_DISABLE BIT(16) #define DWC3_GUCTL3_SPLITDISABLE BIT(14) /* Device Configuration Register */ From 72fc4d24153f1bbe4932b955bf415aeb81d5bf30 Mon Sep 17 00:00:00 2001 From: Mohammed Mirza Mandayappurath Manzoor Date: Tue, 18 Jan 2022 16:06:24 -0800 Subject: [PATCH 25/48] msm: kgsl: Zap performance counters across context switches Performance counter values need not be retained across contexts unless specifically requested for debug. Zap the counters by initialising perfcounter SRAM with 0's using GPU_RBBM_PERFCTR_SRAM_INIT_CMD. Add pm4 packets during context switches and add a KMD postamble packet to clear the counters during preemption. Do not enable perfcounter save and restore unless requested. Change-Id: I371779ce659c07a1cc664327f5ecdcf0374201d8 Signed-off-by: Mohammed Mirza Mandayappurath Manzoor Signed-off-by: Harshitha Sai Neelati --- drivers/gpu/msm/a6xx_reg.h | 3 ++ drivers/gpu/msm/adreno.h | 8 +++++ drivers/gpu/msm/adreno_a6xx_preempt.c | 44 ++++++++++++++++++++++++--- drivers/gpu/msm/adreno_iommu.c | 18 +++++++++++ drivers/gpu/msm/adreno_perfcounter.c | 7 +++-- drivers/gpu/msm/adreno_pm4types.h | 7 +++++ drivers/gpu/msm/adreno_ringbuffer.c | 3 +- 7 files changed, 83 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/msm/a6xx_reg.h b/drivers/gpu/msm/a6xx_reg.h index 9d16d09cb3d2..df52db8ac6d1 100644 --- a/drivers/gpu/msm/a6xx_reg.h +++ b/drivers/gpu/msm/a6xx_reg.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _A6XX_REG_H @@ -406,6 +407,8 @@ #define A6XX_RBBM_PERFCTR_RBBM_SEL_2 0x509 #define A6XX_RBBM_PERFCTR_RBBM_SEL_3 0x50A #define A6XX_RBBM_PERFCTR_GPU_BUSY_MASKED 0x50B +#define A6XX_RBBM_PERFCTR_SRAM_INIT_CMD 0x50e +#define A6XX_RBBM_PERFCTR_SRAM_INIT_STATUS 0x50f #define A6XX_RBBM_ISDB_CNT 0x533 #define A6XX_RBBM_NC_MODE_CNTL 0X534 diff --git a/drivers/gpu/msm/adreno.h b/drivers/gpu/msm/adreno.h index e7dd6c18a6ad..ac685b24144b 100644 --- a/drivers/gpu/msm/adreno.h +++ b/drivers/gpu/msm/adreno.h @@ -16,6 +16,9 @@ #include "adreno_ringbuffer.h" #include "kgsl_sharedmem.h" +/* Index to preemption scratch buffer to store KMD postamble */ +#define KMD_POSTAMBLE_IDX 100 + /* ADRENO_DEVICE - Given a kgsl_device return the adreno device struct */ #define ADRENO_DEVICE(device) \ container_of(device, struct adreno_device, dev) @@ -232,6 +235,9 @@ struct adreno_gpudev; /* Time to allow preemption to complete (in ms) */ #define ADRENO_PREEMPT_TIMEOUT 10000 +#define PREEMPT_SCRATCH_ADDR(dev, id) \ + ((dev)->preempt.scratch->gpuaddr + (id * sizeof(u64))) + /** * enum adreno_preempt_states * ADRENO_PREEMPT_NONE: No preemption is scheduled @@ -261,6 +267,7 @@ enum adreno_preempt_states { * skipsaverestore: To skip saverestore during L1 preemption (for 6XX) * usesgmem: enable GMEM save/restore across preemption (for 6XX) * count: Track the number of preemptions triggered + * @postamble_len: Number of dwords in KMD postamble pm4 packet */ struct adreno_preemption { atomic_t state; @@ -271,6 +278,7 @@ struct adreno_preemption { bool skipsaverestore; bool usesgmem; unsigned int count; + u32 postamble_len; }; struct adreno_busy_data { diff --git a/drivers/gpu/msm/adreno_a6xx_preempt.c b/drivers/gpu/msm/adreno_a6xx_preempt.c index 49b082dd0e7c..f0c5cf5a4869 100644 --- a/drivers/gpu/msm/adreno_a6xx_preempt.c +++ b/drivers/gpu/msm/adreno_a6xx_preempt.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include "adreno.h" @@ -543,13 +544,24 @@ unsigned int a6xx_preemption_pre_ibsubmit( if (context) { struct adreno_context *drawctxt = ADRENO_CONTEXT(context); struct adreno_ringbuffer *rb = drawctxt->rb; - uint64_t dest = adreno_dev->preempt.scratch->gpuaddr - + (rb->id * sizeof(u64)); + uint64_t dest = PREEMPT_SCRATCH_ADDR(adreno_dev, rb->id); *cmds++ = cp_mem_packet(adreno_dev, CP_MEM_WRITE, 2, 2); cmds += cp_gpuaddr(adreno_dev, cmds, dest); *cmds++ = lower_32_bits(gpuaddr); *cmds++ = upper_32_bits(gpuaddr); + + /* Add a KMD post amble to clear the perf counters during preemption */ + if (!adreno_dev->perfcounter) { + u64 kmd_postamble_addr = + PREEMPT_SCRATCH_ADDR(adreno_dev, KMD_POSTAMBLE_IDX); + + *cmds++ = cp_type7_packet(CP_SET_AMBLE, 3); + *cmds++ = lower_32_bits(kmd_postamble_addr); + *cmds++ = upper_32_bits(kmd_postamble_addr); + *cmds++ = FIELD_PREP(GENMASK(22, 20), CP_KMD_AMBLE_TYPE) + | (FIELD_PREP(GENMASK(19, 0), adreno_dev->preempt.postamble_len)); + } } return (unsigned int) (cmds - cmds_orig); @@ -562,8 +574,7 @@ unsigned int a6xx_preemption_post_ibsubmit(struct adreno_device *adreno_dev, struct adreno_ringbuffer *rb = adreno_dev->cur_rb; if (rb) { - uint64_t dest = adreno_dev->preempt.scratch->gpuaddr - + (rb->id * sizeof(u64)); + uint64_t dest = PREEMPT_SCRATCH_ADDR(adreno_dev, adreno_dev->cur_rb->id); *cmds++ = cp_mem_packet(adreno_dev, CP_MEM_WRITE, 2, 2); cmds += cp_gpuaddr(adreno_dev, cmds, dest); @@ -721,6 +732,31 @@ int a6xx_preemption_init(struct adreno_device *adreno_dev) if (ret) return ret; + /* + * First 8 dwords of the preemption scratch buffer is used to store the address for CP + * to save/restore VPC data. Reserve 11 dwords in the preemption scratch buffer from + * index KMD_POSTAMBLE_IDX for KMD postamble pm4 packets + */ + if (!adreno_dev->perfcounter) { + u32 *postamble = preempt->scratch->hostptr + (KMD_POSTAMBLE_IDX * sizeof(u64)); + u32 count = 0; + + postamble[count++] = cp_type7_packet(CP_REG_RMW, 3); + postamble[count++] = A6XX_RBBM_PERFCTR_SRAM_INIT_CMD; + postamble[count++] = 0x0; + postamble[count++] = 0x1; + + postamble[count++] = cp_type7_packet(CP_WAIT_REG_MEM, 6); + postamble[count++] = 0x3; + postamble[count++] = A6XX_RBBM_PERFCTR_SRAM_INIT_STATUS; + postamble[count++] = 0x0; + postamble[count++] = 0x1; + postamble[count++] = 0x1; + postamble[count++] = 0x0; + + preempt->postamble_len = count; + } + set_bit(ADRENO_DEVICE_PREEMPTION, &adreno_dev->priv); return 0; } diff --git a/drivers/gpu/msm/adreno_iommu.c b/drivers/gpu/msm/adreno_iommu.c index 73e6016bf1d9..be88bafb12da 100644 --- a/drivers/gpu/msm/adreno_iommu.c +++ b/drivers/gpu/msm/adreno_iommu.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2002,2007-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -217,6 +218,12 @@ static unsigned int _adreno_iommu_set_pt_v2_a6xx(struct kgsl_device *device, struct adreno_device *adreno_dev = ADRENO_DEVICE(device); unsigned int *cmds = cmds_orig; + /* Clear performance counters during contect switches */ + if (!adreno_dev->perfcounter) { + *cmds++ = cp_type4_packet(A6XX_RBBM_PERFCTR_SRAM_INIT_CMD, 1); + *cmds++ = 0x1; + } + /* CP switches the pagetable and flushes the Caches */ *cmds++ = cp_packet(adreno_dev, CP_SMMU_TABLE_UPDATE, 4); *cmds++ = lower_32_bits(ttbr0); @@ -245,6 +252,17 @@ static unsigned int _adreno_iommu_set_pt_v2_a6xx(struct kgsl_device *device, *cmds++ = 0; } + /* Wait for performance counter clear to finish */ + if (!adreno_dev->perfcounter) { + *cmds++ = cp_type7_packet(CP_WAIT_REG_MEM, 6); + *cmds++ = 0x3; + *cmds++ = A6XX_RBBM_PERFCTR_SRAM_INIT_STATUS; + *cmds++ = 0x0; + *cmds++ = 0x1; + *cmds++ = 0x1; + *cmds++ = 0x0; + } + return cmds - cmds_orig; } diff --git a/drivers/gpu/msm/adreno_perfcounter.c b/drivers/gpu/msm/adreno_perfcounter.c index d0b0bd3a2846..49ff0356a065 100644 --- a/drivers/gpu/msm/adreno_perfcounter.c +++ b/drivers/gpu/msm/adreno_perfcounter.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2002,2007-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -72,7 +73,8 @@ void adreno_perfcounter_restore(struct adreno_device *adreno_dev) const struct adreno_perfcount_group *group; unsigned int counter, groupid; - if (counters == NULL) + /* Do not save/restore if not requested */ + if (counters == NULL || !adreno_dev->perfcounter) return; for (groupid = 0; groupid < counters->group_count; groupid++) { @@ -106,7 +108,8 @@ inline void adreno_perfcounter_save(struct adreno_device *adreno_dev) const struct adreno_perfcount_group *group; unsigned int counter, groupid; - if (counters == NULL) + /* Do not save/restore if not requested */ + if (counters == NULL || !adreno_dev->perfcounter) return; for (groupid = 0; groupid < counters->group_count; groupid++) { diff --git a/drivers/gpu/msm/adreno_pm4types.h b/drivers/gpu/msm/adreno_pm4types.h index b64492044400..deb54dcc6ccc 100644 --- a/drivers/gpu/msm/adreno_pm4types.h +++ b/drivers/gpu/msm/adreno_pm4types.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2002,2007-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __ADRENO_PM4TYPES_H #define __ADRENO_PM4TYPES_H @@ -47,6 +48,9 @@ /* switches SMMU pagetable, used on a5xx only */ #define CP_SMMU_TABLE_UPDATE 0x53 +/* Designate command streams to be executed before/after CP does state restore during preemption */ +#define CP_SET_AMBLE 0x55 + /* Set internal CP registers, used to indicate context save data addresses */ #define CP_SET_PSEUDO_REGISTER 0x56 @@ -157,6 +161,9 @@ #define CP_LOADSTATE_STATETYPE_SHIFT 0x00000000 #define CP_LOADSTATE_EXTSRCADDR_SHIFT 0x00000002 +/* Used to define amble type in SET_AMBLE packet to execute during preemption */ +#define CP_KMD_AMBLE_TYPE 3 + static inline uint pm4_calc_odd_parity_bit(uint val) { return (0x9669 >> (0xf & ((val) ^ diff --git a/drivers/gpu/msm/adreno_ringbuffer.c b/drivers/gpu/msm/adreno_ringbuffer.c index 33e67cd0390a..0e25e7bfcf81 100644 --- a/drivers/gpu/msm/adreno_ringbuffer.c +++ b/drivers/gpu/msm/adreno_ringbuffer.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2002,2007-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -482,7 +483,7 @@ adreno_ringbuffer_addcmds(struct adreno_ringbuffer *rb, if (gpudev->preemption_pre_ibsubmit && adreno_is_preemption_enabled(adreno_dev)) - total_sizedwords += 27; + total_sizedwords += 31; if (gpudev->preemption_post_ibsubmit && adreno_is_preemption_enabled(adreno_dev)) From 90bd82d3f86447b0a5412352015784fa57ec80db Mon Sep 17 00:00:00 2001 From: Sandeep Singh Date: Tue, 1 Mar 2022 14:23:52 +0530 Subject: [PATCH 26/48] icnss2: Add code to pass device configs to wlan driver Add code to pass device configs to wlan driver. Change-Id: I977fc564914f9fbdabc0004eff4c5c2f14a1fc7c Signed-off-by: Sandeep Singh --- drivers/soc/qcom/icnss2/main.c | 21 +++++++++++++++++++++ drivers/soc/qcom/icnss2/main.h | 1 + include/soc/qcom/icnss2.h | 5 +++++ 3 files changed, 27 insertions(+) diff --git a/drivers/soc/qcom/icnss2/main.c b/drivers/soc/qcom/icnss2/main.c index dc873a24e54f..462d4bb807d7 100644 --- a/drivers/soc/qcom/icnss2/main.c +++ b/drivers/soc/qcom/icnss2/main.c @@ -400,6 +400,17 @@ bool icnss_is_fw_down(void) } EXPORT_SYMBOL(icnss_is_fw_down); +unsigned long icnss_get_device_config(void) +{ + struct icnss_priv *priv = icnss_get_plat_priv(); + + if (!priv) + return 0; + + return priv->device_config; +} +EXPORT_SYMBOL(icnss_get_device_config); + bool icnss_is_rejuvenate(void) { if (!penv) @@ -3905,6 +3916,14 @@ static void icnss_init_control_params(struct icnss_priv *priv) } } +static void icnss_read_device_configs(struct icnss_priv *priv) +{ + if (of_property_read_bool(priv->pdev->dev.of_node, + "wlan-ipa-disabled")) { + set_bit(ICNSS_IPA_DISABLED, &priv->device_config); + } +} + static inline void icnss_get_smp2p_info(struct icnss_priv *priv) { @@ -4007,6 +4026,8 @@ static int icnss_probe(struct platform_device *pdev) icnss_init_control_params(priv); + icnss_read_device_configs(priv); + ret = icnss_resource_parse(priv); if (ret) goto out_reset_drvdata; diff --git a/drivers/soc/qcom/icnss2/main.h b/drivers/soc/qcom/icnss2/main.h index b75767a07af0..8ff61897b8a9 100644 --- a/drivers/soc/qcom/icnss2/main.h +++ b/drivers/soc/qcom/icnss2/main.h @@ -465,6 +465,7 @@ struct icnss_priv { struct icnss_dms_data dms; u8 use_nv_mac; u32 wlan_en_delay_ms; + unsigned long device_config; }; struct icnss_reg_info { diff --git a/include/soc/qcom/icnss2.h b/include/soc/qcom/icnss2.h index cca3a95be74a..19510f022e12 100644 --- a/include/soc/qcom/icnss2.h +++ b/include/soc/qcom/icnss2.h @@ -23,6 +23,10 @@ enum icnss_uevent { ICNSS_UEVENT_SMMU_FAULT, }; +enum icnss_device_config { + ICNSS_IPA_DISABLED, +}; + struct icnss_uevent_hang_data { void *hang_event_data; uint16_t hang_event_data_len; @@ -196,4 +200,5 @@ extern int icnss_prevent_l1(struct device *dev); extern void icnss_allow_l1(struct device *dev); extern int icnss_get_mhi_state(struct device *dev); extern int icnss_is_pci_ep_awake(struct device *dev); +extern unsigned long icnss_get_device_config(void); #endif /* _ICNSS_WLAN_H_ */ From dfe4a47b7e48ef7e35238d8a0841a48ab842c1a0 Mon Sep 17 00:00:00 2001 From: Pradeep P V K Date: Wed, 9 Mar 2022 10:56:08 +0530 Subject: [PATCH 27/48] ubi: Use UBI_MAX_VOLUME_NAME for printing ubi volume names Use UBI_MAX_VOLUME_NAME length for printing ubi volume names to avoid truncation of ubi volume name fields. Change-Id: I0ab4577dcc1e4bb93d2bcef1b8e52da98f13ff15 Signed-off-by: Pradeep P V K --- drivers/mtd/ubi/vmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index 327f369d9fd0..e1fa76b88469 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c @@ -86,7 +86,7 @@ static ssize_t vol_attribute_show(struct device *dev, } ret = scnprintf(buf, size, "%s\n", tp); } else if (attr == &attr_vol_name) - ret = scnprintf(buf, vol->name_len + 1, "%s\n", + ret = scnprintf(buf, UBI_MAX_VOLUME_NAME + 1, "%s\n", vol->name); else if (attr == &attr_vol_corrupted) ret = scnprintf(buf, sizeof(int), "%d\n", From 09c66295317779dc3e27c11a553f6044998d7003 Mon Sep 17 00:00:00 2001 From: Jiri Bohac Date: Wed, 26 Jan 2022 16:00:18 +0100 Subject: [PATCH 28/48] Revert "xfrm: xfrm_state_mtu should return at least 1280 for ipv6" This reverts commit b515d2637276a3810d6595e10ab02c13bfd0b63a. Commit b515d2637276a3810d6595e10ab02c13bfd0b63a ("xfrm: xfrm_state_mtu should return at least 1280 for ipv6") in v5.14 breaks the TCP MSS calculation in ipsec transport mode, resulting complete stalls of TCP connections. This happens when the (P)MTU is 1280 or slighly larger. The desired formula for the MSS is: MSS = (MTU - ESP_overhead) - IP header - TCP header However, the above commit clamps the (MTU - ESP_overhead) to a minimum of 1280, turning the formula into MSS = max(MTU - ESP overhead, 1280) - IP header - TCP header With the (P)MTU near 1280, the calculated MSS is too large and the resulting TCP packets never make it to the destination because they are over the actual PMTU. The above commit also causes suboptimal double fragmentation in xfrm tunnel mode, as described in https://lore.kernel.org/netdev/20210429202529.codhwpc7w6kbudug@dwarf.suse.cz/ The original problem the above commit was trying to fix is now fixed by commit 6596a0229541270fb8d38d989f91b78838e5e9da ("xfrm: fix MTU regression"). Change-Id: Iefabad76eb1870f74b819f45e9d3a51cbc94549c Signed-off-by: Jiri Bohac Signed-off-by: Steffen Klassert Git-commit: a6d95c5a628a09be129f25d5663a7e9db8261f51 Git-repo: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git Signed-off-by: Sharath Chandra Vurukala --- include/net/xfrm.h | 1 - net/ipv4/esp4.c | 2 +- net/ipv6/esp6.c | 2 +- net/xfrm/xfrm_state.c | 14 ++------------ 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 46e0e38f6003..094aafef7d6d 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -1543,7 +1543,6 @@ void xfrm_sad_getinfo(struct net *net, struct xfrmk_sadinfo *si); void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si); u32 xfrm_replay_seqhi(struct xfrm_state *x, __be32 net_seq); int xfrm_init_replay(struct xfrm_state *x); -u32 __xfrm_state_mtu(struct xfrm_state *x, int mtu); u32 xfrm_state_mtu(struct xfrm_state *x, int mtu); int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload); int xfrm_init_state(struct xfrm_state *x); diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index 86c836fa2145..00210e55b4cd 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c @@ -499,7 +499,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb) struct xfrm_dst *dst = (struct xfrm_dst *)skb_dst(skb); u32 padto; - padto = min(x->tfcpad, __xfrm_state_mtu(x, dst->child_mtu_cached)); + padto = min(x->tfcpad, xfrm_state_mtu(x, dst->child_mtu_cached)); if (skb->len < padto) esp.tfclen = padto - skb->len; } diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c index 12570a73def8..7a739f16d82b 100644 --- a/net/ipv6/esp6.c +++ b/net/ipv6/esp6.c @@ -440,7 +440,7 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb) struct xfrm_dst *dst = (struct xfrm_dst *)skb_dst(skb); u32 padto; - padto = min(x->tfcpad, __xfrm_state_mtu(x, dst->child_mtu_cached)); + padto = min(x->tfcpad, xfrm_state_mtu(x, dst->child_mtu_cached)); if (skb->len < padto) esp.tfclen = padto - skb->len; } diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index ea46d894063e..8bb052bb137e 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -2517,7 +2517,7 @@ void xfrm_state_delete_tunnel(struct xfrm_state *x) } EXPORT_SYMBOL(xfrm_state_delete_tunnel); -u32 __xfrm_state_mtu(struct xfrm_state *x, int mtu) +u32 xfrm_state_mtu(struct xfrm_state *x, int mtu) { const struct xfrm_type *type = READ_ONCE(x->type); struct crypto_aead *aead; @@ -2548,17 +2548,7 @@ u32 __xfrm_state_mtu(struct xfrm_state *x, int mtu) return ((mtu - x->props.header_len - crypto_aead_authsize(aead) - net_adj) & ~(blksize - 1)) + net_adj - 2; } -EXPORT_SYMBOL_GPL(__xfrm_state_mtu); - -u32 xfrm_state_mtu(struct xfrm_state *x, int mtu) -{ - mtu = __xfrm_state_mtu(x, mtu); - - if (x->props.family == AF_INET6 && mtu < IPV6_MIN_MTU) - return IPV6_MIN_MTU; - - return mtu; -} +EXPORT_SYMBOL_GPL(xfrm_state_mtu); int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload) { From b3a8a1b14306c8a44470f8352832f0ea682bd48d Mon Sep 17 00:00:00 2001 From: Fenglin Wu Date: Mon, 14 Mar 2022 14:44:48 +0800 Subject: [PATCH 29/48] input: qcom-hv-haptics: config open-loop drive when hBoost is enabled With commit 8c194abb0ec8 ("input: qcom-hv-haptics: delay hBoost turning off"), the hBoost would be kept as enabled in the 2 seconds after stopping play. If a new play is triggered in that 2 seconds, the hBoost will be considered as working in open-loop mode so configure haptics open-loop drive in such case. Change-Id: Ibfa533f23a52bd609e2a8564f859ca8835a8fd67 Signed-off-by: Fenglin Wu --- drivers/input/misc/qcom-hv-haptics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/misc/qcom-hv-haptics.c b/drivers/input/misc/qcom-hv-haptics.c index 19114337368a..5682800756b1 100644 --- a/drivers/input/misc/qcom-hv-haptics.c +++ b/drivers/input/misc/qcom-hv-haptics.c @@ -1474,7 +1474,7 @@ static int haptics_open_loop_drive_config(struct haptics_chip *chip, bool en) u8 val; if ((is_boost_vreg_enabled_in_open_loop(chip) || - is_haptics_external_powered(chip)) && en) { + chip->hboost_enabled || is_haptics_external_powered(chip)) && en) { /* Force VREG_RDY */ rc = haptics_masked_write(chip, chip->cfg_addr_base, HAP_CFG_VSET_CFG_REG, FORCE_VREG_RDY_BIT, From 6bf118c8937f581753bc5c61c0e06f34ab2b4bfa Mon Sep 17 00:00:00 2001 From: Sai Chaitanya Kaveti Date: Mon, 21 Feb 2022 13:10:57 +0530 Subject: [PATCH 30/48] msm: mhi_dev: Avoiding ereq memory allocation in start Start channel commands from MHI Host are given for all the set of valid channels during the initialization itself. Previously we are allocating ereq memory as part of start channel command. But, many of these channels may not be opened by the clients and the ereq memory allocated is not useful here. Here avoiding ereq memory allocation during start channel command and allocating memory only as part of open channel call by the clients. This will reduce the overall memory usage and avoid the memory allocation failures. Change-Id: I60eccd1d17c60e1108820e1532f2ae385455f336 Signed-off-by: Sai Chaitanya Kaveti --- drivers/platform/msm/mhi_dev/mhi.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/platform/msm/mhi_dev/mhi.c b/drivers/platform/msm/mhi_dev/mhi.c index 56b846e18f89..23a78b8fcd78 100644 --- a/drivers/platform/msm/mhi_dev/mhi.c +++ b/drivers/platform/msm/mhi_dev/mhi.c @@ -1873,9 +1873,11 @@ static void mhi_dev_process_reset_cmd(struct mhi_dev *mhi, int ch_id) * event in the next flush operation. */ spin_lock_irqsave(&mhi_ctx->lock, flags); - list_for_each_entry_safe(itr, tmp, &ch->flush_event_req_buffers, list) { - list_del(&itr->list); - kfree(itr); + if (!list_empty(&ch->flush_event_req_buffers)) { + list_for_each_entry_safe(itr, tmp, &ch->flush_event_req_buffers, list) { + list_del(&itr->list); + kfree(itr); + } } spin_unlock_irqrestore(&mhi_ctx->lock, flags); @@ -1991,16 +1993,6 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, goto send_undef_completion_event; } } - mutex_lock(&mhi->ch[ch_id].ch_lock); - rc = mhi_dev_alloc_evt_buf_evt_req(mhi, &mhi->ch[ch_id], - evt_ring); - mutex_unlock(&mhi->ch[ch_id].ch_lock); - if (rc) { - mhi_log(MHI_MSG_ERROR, - "Failed to alloc ereqs for er %d\n", - mhi->ch_ctx_cache[ch_id].err_indx); - goto send_undef_completion_event; - } } if (MHI_USE_DMA(mhi)) @@ -3080,10 +3072,7 @@ static int mhi_dev_alloc_evt_buf_evt_req(struct mhi_dev *mhi, int rc; uint32_t size, i; - if (evt_ring) - size = evt_ring->ring_size; - else - size = mhi_dev_get_evt_ring_size(mhi, ch->ch_id); + size = mhi_dev_get_evt_ring_size(mhi, ch->ch_id); if (!size) { mhi_log(MHI_MSG_ERROR, @@ -4122,6 +4111,8 @@ static int mhi_init(struct mhi_dev *mhi) for (i = 0; i < mhi->cfg.channels; i++) { mhi->ch[i].ch_id = i; mutex_init(&mhi->ch[i].ch_lock); + INIT_LIST_HEAD(&mhi->ch[i].event_req_buffers); + INIT_LIST_HEAD(&mhi->ch[i].flush_event_req_buffers); } } From 224fd98c51469fa3428740168b557b4da0ba08e1 Mon Sep 17 00:00:00 2001 From: Yuanfang Zhang Date: Tue, 8 Mar 2022 16:01:51 +0800 Subject: [PATCH 31/48] byte-cntr: check pcie channel status before closing it Check pcie channel status before call the close channel API, only closed it when it in open state. Change-Id: Ib3bee9575edfae0cc907baee4956d6e3a6c78d61 Signed-off-by: Yuanfang Zhang --- drivers/hwtracing/coresight/coresight-byte-cntr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-byte-cntr.c b/drivers/hwtracing/coresight/coresight-byte-cntr.c index 07250b388b56..9c500245b4e2 100644 --- a/drivers/hwtracing/coresight/coresight-byte-cntr.c +++ b/drivers/hwtracing/coresight/coresight-byte-cntr.c @@ -182,7 +182,7 @@ EXPORT_SYMBOL(tmc_etr_byte_cntr_stop); static void etr_pcie_close_channel(struct byte_cntr *byte_cntr_data) { - if (!byte_cntr_data) + if (!byte_cntr_data || !byte_cntr_data->pcie_chan_opened) return; mutex_lock(&byte_cntr_data->byte_cntr_lock); From 77221bae90fd186833aa30def073da0d3ea71ba7 Mon Sep 17 00:00:00 2001 From: Sai Chaitanya Kaveti Date: Mon, 21 Feb 2022 14:32:50 +0530 Subject: [PATCH 32/48] msm: mhi_dev: Avoiding freeing of ereq memory in reset With the commit <1528bbe6b570> ("msm: mhi_dev: Keeping event req memory without clearing in close channel"), we are avoiding freeing of ereq memory in close channel API. New memory is not created again as part of start/open channel since it is not released while closing the channel. Idea is to hold the allocated memory and avoid reallocating every time. But during the reset command we are freeing some of the ereqs which we need to hold without releasing. This change avoids freeing of ereq memory as part of reset channel command and adds the ereqs to the event_req_buffers list. This ensures that the lists, event_req_buffers and flush_event_req_buffers are updated with valid ereqs. Change-Id: Ie29962f2bc8ef5a0c193d13a13118ae9b6044c0b Signed-off-by: Sai Chaitanya Kaveti --- drivers/platform/msm/mhi_dev/mhi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/platform/msm/mhi_dev/mhi.c b/drivers/platform/msm/mhi_dev/mhi.c index 23a78b8fcd78..eed0707ac886 100644 --- a/drivers/platform/msm/mhi_dev/mhi.c +++ b/drivers/platform/msm/mhi_dev/mhi.c @@ -1868,15 +1868,15 @@ static void mhi_dev_process_reset_cmd(struct mhi_dev *mhi, int ch_id) mhi_log(MHI_MSG_VERBOSE, "Processing reset cmd for ch%d\n", ch_id); /* * Ensure that the completions that are present in the flush list are - * removed from the list and discarded before stopping the channel. - * Otherwise, those stale events may get flushed along with a valid - * event in the next flush operation. + * removed from the list and added to event req list before channel + * reset. Otherwise, those stale events may get flushed along with a + * valid event in the next flush operation. */ spin_lock_irqsave(&mhi_ctx->lock, flags); if (!list_empty(&ch->flush_event_req_buffers)) { list_for_each_entry_safe(itr, tmp, &ch->flush_event_req_buffers, list) { list_del(&itr->list); - kfree(itr); + list_add_tail(&itr->list, &ch->event_req_buffers); } } spin_unlock_irqrestore(&mhi_ctx->lock, flags); From f62c200442a3e99181b3f84bb0ff1d653aebee3d Mon Sep 17 00:00:00 2001 From: Sai Chaitanya Kaveti Date: Tue, 15 Feb 2022 12:07:13 +0530 Subject: [PATCH 33/48] msm: mhi_dev: Using channel mutex lock for channel specific lists Using channel mutex lock while accessing channel specific lists, event_req_buffers and flush_event_req_buffers. This will avoid any synchronization issues for these lists. Previously two different mutex locks, global MHI lock and channel lock are used while accessing these lists. Removing MHI spin lock while accessing the above lists in mhi_dev_process_reset_cmd, mhi_dev_queue_transfer_completion and mhi_dev_flush_transfer_completion_events APIs as they are already protected by channel mutex lock obtained from the APIs that are calling these three APIs. Removing MHI spin lock in mhi_dev_event_msi_cb and adding channel mutex lock. In other instances where these lists are accessed they are already protected by channel mutex lock. Change-Id: I58b673be452a942ff946e07f17c96a0715805621 Signed-off-by: Sai Chaitanya Kaveti --- drivers/platform/msm/mhi_dev/mhi.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/platform/msm/mhi_dev/mhi.c b/drivers/platform/msm/mhi_dev/mhi.c index eed0707ac886..99a7cca705ad 100644 --- a/drivers/platform/msm/mhi_dev/mhi.c +++ b/drivers/platform/msm/mhi_dev/mhi.c @@ -380,7 +380,7 @@ static void mhi_dev_event_msi_cb(void *req) if (ch->evt_buf_wp == ch->evt_buf_size) ch->evt_buf_wp = 0; /* Return the event req to the list */ - spin_lock_irqsave(&mhi->lock, flags); + mutex_lock(&ch->ch_lock); if (ch->curr_ereq == NULL) ch->curr_ereq = ereq; else { @@ -388,7 +388,7 @@ static void mhi_dev_event_msi_cb(void *req) ereq->is_stale = false; list_add_tail(&ereq->list, &ch->event_req_buffers); } - spin_unlock_irqrestore(&mhi->lock, flags); + mutex_unlock(&ch->ch_lock); } static void msi_trigger_completion_cb(void *data) @@ -646,15 +646,12 @@ static int mhi_dev_flush_transfer_completion_events(struct mhi_dev *mhi, break; } - spin_lock_irqsave(&mhi->lock, flags); if (list_empty(&ch->flush_event_req_buffers)) { - spin_unlock_irqrestore(&mhi->lock, flags); break; } flush_ereq = container_of(ch->flush_event_req_buffers.next, struct event_req, list); list_del_init(&flush_ereq->list); - spin_unlock_irqrestore(&mhi->lock, flags); if (ch->flush_req_cnt++ >= U32_MAX) ch->flush_req_cnt = 0; @@ -792,7 +789,6 @@ static int mhi_dev_queue_transfer_completion(struct mhi_req *mreq, bool *flush) ch->curr_ereq->context = ch; /* Move current event req to flush list*/ - spin_lock_irqsave(&mhi_ctx->lock, flags); list_add_tail(&ch->curr_ereq->list, &ch->flush_event_req_buffers); @@ -809,7 +805,6 @@ static int mhi_dev_queue_transfer_completion(struct mhi_req *mreq, bool *flush) "evt req buffers empty\n"); ch->curr_ereq = NULL; } - spin_unlock_irqrestore(&mhi_ctx->lock, flags); } return 0; } @@ -1872,14 +1867,12 @@ static void mhi_dev_process_reset_cmd(struct mhi_dev *mhi, int ch_id) * reset. Otherwise, those stale events may get flushed along with a * valid event in the next flush operation. */ - spin_lock_irqsave(&mhi_ctx->lock, flags); if (!list_empty(&ch->flush_event_req_buffers)) { list_for_each_entry_safe(itr, tmp, &ch->flush_event_req_buffers, list) { list_del(&itr->list); list_add_tail(&itr->list, &ch->event_req_buffers); } } - spin_unlock_irqrestore(&mhi_ctx->lock, flags); /* hard stop and set the channel to stop */ mhi->ch_ctx_cache[ch_id].ch_state = From 27d0208340f53381e7df64220190ec81d0740a88 Mon Sep 17 00:00:00 2001 From: Raghavendar rao l Date: Mon, 1 Nov 2021 16:39:12 +0530 Subject: [PATCH 34/48] msm: ipa: Add support for IPA_v5_2 version Added IPA-5.2 version support in header files. Change-Id: I47f2ab4205eeb6875d755152ff7153c5256bdf93 Signed-off-by: Raghavendar rao l --- include/uapi/linux/msm_ipa.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/msm_ipa.h b/include/uapi/linux/msm_ipa.h index 8e04fd625b97..cef39e28803a 100644 --- a/include/uapi/linux/msm_ipa.h +++ b/include/uapi/linux/msm_ipa.h @@ -1005,8 +1005,9 @@ enum ipa_hw_type { IPA_HW_v4_11 = 20, IPA_HW_v5_0 = 21, IPA_HW_v5_1 = 22, + IPA_HW_v5_2 = 23, }; -#define IPA_HW_MAX (IPA_HW_v5_1 + 1) +#define IPA_HW_MAX (IPA_HW_v5_2 + 1) #define IPA_HW_v4_0 IPA_HW_v4_0 #define IPA_HW_v4_1 IPA_HW_v4_1 @@ -1017,6 +1018,7 @@ enum ipa_hw_type { #define IPA_HW_v4_11 IPA_HW_v4_11 #define IPA_HW_v5_0 IPA_HW_v5_0 #define IPA_HW_v5_1 IPA_HW_v5_1 +#define IPA_HW_v5_2 IPA_HW_v5_2 /** * enum ipa_hw_feature_support - IPA HW supported feature From c38c0c90d733f47b5d15e0a14e747ce9b043fcc2 Mon Sep 17 00:00:00 2001 From: Fenglin Wu Date: Tue, 1 Mar 2022 09:52:26 +0800 Subject: [PATCH 35/48] input: qcom-hv-haptics: discard 1-byte FIFO write for HAP_PTN_V2 For haptics module with HAP_PTN_V2 revision, the HW would only read 1 valid byte in every 4 bytes if the 1-byte FIFO write clashes with the FIFO read operation. To avoid this, don't use 1-byte write but just pad zeros at end of the pattern to keep the samples 4-byte aligned and always use 4-byte write for FIFO programming. Change-Id: I3ebde0fe7378c0dcffb5c51e15e6ffaae5af3e29 Signed-off-by: Fenglin Wu --- drivers/input/misc/qcom-hv-haptics.c | 60 +++++++++++++++++----------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/drivers/input/misc/qcom-hv-haptics.c b/drivers/input/misc/qcom-hv-haptics.c index 5682800756b1..029970344159 100644 --- a/drivers/input/misc/qcom-hv-haptics.c +++ b/drivers/input/misc/qcom-hv-haptics.c @@ -1818,13 +1818,17 @@ static int haptics_set_manual_rc_clk_cal(struct haptics_chip *chip) static int haptics_update_fifo_samples(struct haptics_chip *chip, u8 *samples, u32 length) { - int rc, count, i; + int rc = 0, count, i, remain; + u8 tmp[HAP_PTN_V2_FIFO_DIN_NUM] = {0}; if (samples == NULL) { dev_err(chip->dev, "no FIFO samples available\n"); return -EINVAL; } + if (!length) + return 0; + if (chip->ptn_revision == HAP_PTN_V1) { for (i = 0; i < length; i++) { rc = haptics_update_fifo_sample_v1(chip, samples[i]); @@ -1833,6 +1837,7 @@ static int haptics_update_fifo_samples(struct haptics_chip *chip, } } else { count = length / HAP_PTN_V2_FIFO_DIN_NUM; + remain = length % HAP_PTN_V2_FIFO_DIN_NUM; for (i = 0; i < count; i++) { rc = haptics_update_fifo_sample_v2(chip, samples, HAP_PTN_V2_FIFO_DIN_NUM); @@ -1842,16 +1847,26 @@ static int haptics_update_fifo_samples(struct haptics_chip *chip, samples += HAP_PTN_V2_FIFO_DIN_NUM; } - if (length % HAP_PTN_V2_FIFO_DIN_NUM) { - rc = haptics_update_fifo_sample_v2(chip, - samples, - length % HAP_PTN_V2_FIFO_DIN_NUM); - if (rc < 0) - return rc; + if (remain) { + /* + * In HAP_PTN_V2 module, when 1-byte FIFO write clashes + * with the HW FIFO read operation, the HW will only read + * 1 valid byte in every 4 bytes FIFO samples. So avoid + * this by keeping the samples 4-byte aligned and always + * use 4-byte write for HAP_PTN_V2 module. + */ + if (chip->ptn_revision == HAP_PTN_V2) { + memcpy(tmp, samples, remain); + rc = haptics_update_fifo_sample_v2(chip, + tmp, HAP_PTN_V2_FIFO_DIN_NUM); + } else { + rc = haptics_update_fifo_sample_v2(chip, + samples, remain); + } } } - return 0; + return rc; } static int haptics_set_fifo_playrate(struct haptics_chip *chip, @@ -1984,6 +1999,10 @@ static int haptics_set_fifo(struct haptics_chip *chip, struct fifo_cfg *fifo) return available; num = min_t(u32, available, num); + /* Keep the FIFO programming 4-byte aligned if FIFO refilling is needed */ + if ((num < fifo->num_s) && (num % HAP_PTN_V2_FIFO_DIN_NUM)) + num = round_down(num, HAP_PTN_V2_FIFO_DIN_NUM); + rc = haptics_update_fifo_samples(chip, fifo->samples, num); if (rc < 0) { dev_err(chip->dev, "write FIFO samples failed, rc=%d\n", rc); @@ -2875,23 +2894,18 @@ static irqreturn_t fifo_empty_irq_handler(int irq, void *data) if (num < 0) goto unlock; - /* - * With HAPTICS_PATTERN module revision 2.0 and above, if use - * 1-byte write before 4-byte write, the hardware would insert - * zeros in between to keep the FIFO samples 4-byte aligned, and - * the inserted 0 values would cause HW stop driving hence spurs - * will be seen on the haptics output. So only use 1-byte write - * at the end of FIFO streaming. - */ - if (samples_left <= num) - num = samples_left; - else if ((chip->ptn_revision >= HAP_PTN_V2) && - (num % HAP_PTN_V2_FIFO_DIN_NUM)) - num -= (num % HAP_PTN_V2_FIFO_DIN_NUM); - samples = fifo->samples + status->samples_written; - /* Write more pattern data into FIFO memory. */ + /* + * Always use 4-byte burst write in the middle of FIFO programming to + * avoid HW padding zeros during 1-byte write which would cause the HW + * stop driving for the unexpected padding zeros. + */ + if (num < samples_left) + num = round_down(num, HAP_PTN_V2_FIFO_DIN_NUM); + else + num = samples_left; + rc = haptics_update_fifo_samples(chip, samples, num); if (rc < 0) { dev_err(chip->dev, "Update FIFO samples failed, rc=%d\n", From 9c99c0fcda604149ce42c5acd418bd3084cdd6c1 Mon Sep 17 00:00:00 2001 From: Odelu Kukatla Date: Thu, 27 May 2021 22:36:49 +0530 Subject: [PATCH 36/48] interconnect: qcom: Limit the maximum frequency to INT_MAX Higher bandwidth vote from client is resulting in overflow in 32-bit mode, so limit the max frequency to INT_MAX. Change-Id: Ic36da4a1797a91db5f840ba444b8d6ea63b96a49 Signed-off-by: Odelu Kukatla --- drivers/interconnect/qcom/icc-rpm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c index f607d9877e1a..1c2b4f3e454d 100644 --- a/drivers/interconnect/qcom/icc-rpm.c +++ b/drivers/interconnect/qcom/icc-rpm.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. * */ @@ -133,6 +133,9 @@ int qcom_icc_rpm_set(struct icc_node *src, struct icc_node *dst) do_div(clk_rate, qn->buswidth); bus_clk_rate[i] = max(bus_clk_rate[i], clk_rate); + + if (bus_clk_rate[i] > RPM_CLK_MAX_LEVEL) + bus_clk_rate[i] = RPM_CLK_MAX_LEVEL; } } From cb5c1649310b482ad82233e59e40fcad33f51d60 Mon Sep 17 00:00:00 2001 From: Swathi K Date: Thu, 10 Mar 2022 01:43:18 +0530 Subject: [PATCH 37/48] msm: adsprpc: Expose remote cdsp status Expose remote cdsp status attribute to know the cdsp device availability. Change-Id: I5f13f0e8b0c46bb23c9e32531e5c6bf3d00b22df Signed-off-by: Swathi K --- drivers/char/adsprpc.c | 93 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/drivers/char/adsprpc.c b/drivers/char/adsprpc.c index 0fe92ba12568..28755e98ddbf 100644 --- a/drivers/char/adsprpc.c +++ b/drivers/char/adsprpc.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ /* Uncomment this block to log an error on every VERIFY failure */ @@ -529,6 +530,8 @@ struct fastrpc_apps { struct hlist_head drivers; spinlock_t hlock; struct device *dev; + /* Indicates fastrpc device node info */ + struct device *dev_fastrpc; unsigned int latency; int rpmsg_register; bool legacy_remote_heap; @@ -547,6 +550,8 @@ struct fastrpc_apps { void *ramdump_handle; bool enable_ramdump; struct mutex mut_uid; + /* Indicates cdsp device status */ + int remote_cdsp_status; }; struct fastrpc_mmap { @@ -2972,6 +2977,39 @@ static int fastrpc_invoke_send(struct smq_invoke_ctx *ctx, return err; } +/* + * name : fastrpc_get_dsp_status + * @in : pointer to fastrpc_apps + * @out : void + * Description : This function reads the property + * string from device node and updates the cdsp device + * avialbility status if the node belongs to cdsp device. + */ + +static void fastrpc_get_dsp_status(struct fastrpc_apps *me) +{ + int ret = -1; + struct device_node *node = NULL; + const char *name = NULL; + + do { + node = of_find_compatible_node(node, NULL, "qcom,pil-tz-generic"); + if (node) { + ret = of_property_read_string(node, "qcom,firmware-name", &name); + if (!strcmp(name, "cdsp")) { + ret = of_device_is_available(node); + me->remote_cdsp_status = ret; + ADSPRPC_INFO("adsprpc: %s: cdsp node found with ret:%x\n", + __func__, ret); + break; + } + } else { + ADSPRPC_ERR("adsprpc: Error: %s: cdsp node not found\n", __func__); + break; + } + } while (1); +} + static void fastrpc_init(struct fastrpc_apps *me) { int i; @@ -6683,6 +6721,52 @@ static int fastrpc_setup_service_locator(struct device *dev, return err; } +/* + * name : remote_cdsp_status_show + * @in : dev : pointer to device node + * attr: pointer to device attribute + * @out : buf : Contains remote cdsp status + * @Description : This function updates the buf with + * remote cdsp status by reading the fastrpc node + * @returns : bytes written to buf + */ + +static ssize_t remote_cdsp_status_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct fastrpc_apps *me = &gfa; + + /* + * Default remote DSP status: 0 + * driver possibly not probed yet or not the main device. + */ + + if (!dev || !dev->driver || + !of_device_is_compatible(dev->of_node, "qcom,msm-fastrpc-compute")) { + ADSPRPC_ERR( + "adsprpc: Error: %s: driver not probed yet or not the main device\n", + __func__); + return 0; + } + + return scnprintf(buf, PAGE_SIZE, "%d", + me->remote_cdsp_status); +} + +/* Remote cdsp status attribute declartion as read only */ +static DEVICE_ATTR_RO(remote_cdsp_status); + +/* Declaring attribute for remote dsp */ +static struct attribute *msm_remote_dsp_attrs[] = { + &dev_attr_remote_cdsp_status.attr, + NULL +}; + +/* Defining remote dsp attributes in attributes group */ +static struct attribute_group msm_remote_dsp_attr_group = { + .attrs = msm_remote_dsp_attrs, +}; + static int fastrpc_probe(struct platform_device *pdev) { int err = 0; @@ -6693,6 +6777,14 @@ static int fastrpc_probe(struct platform_device *pdev) if (of_device_is_compatible(dev->of_node, "qcom,msm-fastrpc-compute")) { + me->dev_fastrpc = dev; + err = sysfs_create_group(&pdev->dev.kobj, &msm_remote_dsp_attr_group); + if (err) { + ADSPRPC_ERR( + "adsprpc: Error: %s: initialization of sysfs create group failed with %d\n", + __func__, err); + goto bail; + } init_secure_vmid_list(dev, "qcom,adsp-remoteheap-vmid", &gcinfo[0].rhvm); fastrpc_init_privileged_gids(dev, "qcom,fastrpc-gids", @@ -6814,6 +6906,7 @@ static int __init fastrpc_device_init(void) } memset(me, 0, sizeof(*me)); fastrpc_init(me); + fastrpc_get_dsp_status(me); me->dev = NULL; me->legacy_remote_heap = false; VERIFY(err, 0 == platform_driver_register(&fastrpc_driver)); From 1f2b7d0f15da210fddd14146506c132e9c9e6fc7 Mon Sep 17 00:00:00 2001 From: Subramanian Ananthanarayanan Date: Tue, 17 Nov 2020 13:31:17 +0530 Subject: [PATCH 38/48] msm: ep_pcie: Avoid ELBI access in PERST assert scenario ELBI access after D3 cold (perst assertion) is not recommended as could be REFCLK is off. Change-Id: I198c984c09321e9f3a4583aa3a2ca8cfe2849fbd Signed-off-by: Subramanian Ananthanarayanan --- drivers/platform/msm/ep_pcie/ep_pcie_core.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/platform/msm/ep_pcie/ep_pcie_core.c b/drivers/platform/msm/ep_pcie/ep_pcie_core.c index 3b663d9fa8c9..98c70fb3a75c 100644 --- a/drivers/platform/msm/ep_pcie/ep_pcie_core.c +++ b/drivers/platform/msm/ep_pcie/ep_pcie_core.c @@ -2021,7 +2021,6 @@ int ep_pcie_core_enable_endpoint(enum ep_pcie_options opt) int ep_pcie_core_disable_endpoint(void) { - u32 val = 0; unsigned long irqsave_flags; struct ep_pcie_dev_t *dev = &ep_pcie_dev; @@ -2051,10 +2050,6 @@ int ep_pcie_core_disable_endpoint(void) } dev->conf_ipa_msi_iatu = false; - val = readl_relaxed(dev->elbi + PCIE20_ELBI_SYS_STTS); - EP_PCIE_DBG(dev, "PCIe V%d: LTSSM_STATE during disable:0x%x\n", - dev->rev, (val >> 0xC) & 0x3f); - EP_PCIE_DBG2(dev, "PCIe V%d: Set pcie_disconnect_req during D3_COLD\n", dev->rev); ep_pcie_write_reg_field(dev->tcsr_perst_en, From ea49b496fddd01805ca575ce5103537668b8e306 Mon Sep 17 00:00:00 2001 From: Sai Chaitanya Kaveti Date: Thu, 24 Mar 2022 14:48:01 +0530 Subject: [PATCH 39/48] msm: mhi_dev: Adding check in open channel API Adding check for mhi_ctx and mhi_ctx->pdev in mhi_dev_open_channel API which is called by the clients. This prevents the device crash when mhi_dev_open_channel is called in PCIe RC configuration or when it is called when mhi_ctx is not created yet. Change-Id: Ic1737fa1090c06153b0638014f014ec7c1ca2903 Signed-off-by: Sai Chaitanya Kaveti --- drivers/platform/msm/mhi_dev/mhi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/platform/msm/mhi_dev/mhi.c b/drivers/platform/msm/mhi_dev/mhi.c index 99a7cca705ad..1c58293b2444 100644 --- a/drivers/platform/msm/mhi_dev/mhi.c +++ b/drivers/platform/msm/mhi_dev/mhi.c @@ -3155,6 +3155,11 @@ int mhi_dev_open_channel(uint32_t chan_id, struct mhi_dev_channel *ch; struct platform_device *pdev; + if (!mhi_ctx || !mhi_ctx->pdev) { + mhi_log(MHI_MSG_ERROR, "Invalid open channel call for ch_id:%d\n", chan_id); + return -EINVAL; + } + pdev = mhi_ctx->pdev; ch = &mhi_ctx->ch[chan_id]; From 866af57747afa7d3e7f05a515dc9dc9e146f0f6c Mon Sep 17 00:00:00 2001 From: Veerabhadrarao Badiganti Date: Thu, 10 Feb 2022 19:27:28 +0530 Subject: [PATCH 40/48] msm: mhi_dev: Update comments and log in mhi_dev_process_ring Update the logs and comments in mhi_dev_process_ring. Change-Id: Ia082911edeb79293d33f82a5001ce99eee4e746d Signed-off-by: Veerabhadrarao Badiganti --- drivers/platform/msm/mhi_dev/mhi_ring.c | 45 +++++++++++++------------ 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/drivers/platform/msm/mhi_dev/mhi_ring.c b/drivers/platform/msm/mhi_dev/mhi_ring.c index e7b6fb4c389e..8ec18330670e 100644 --- a/drivers/platform/msm/mhi_dev/mhi_ring.c +++ b/drivers/platform/msm/mhi_dev/mhi_ring.c @@ -192,9 +192,12 @@ int mhi_dev_process_ring_element(struct mhi_dev_ring *ring, size_t offset) /* get the element and invoke the respective callback */ el = &ring->ring_cache[offset]; - mhi_log(MHI_MSG_VERBOSE, "evnt ptr : 0x%llx\n", el->tre.data_buf_ptr); - mhi_log(MHI_MSG_VERBOSE, "evnt len : 0x%x, offset:%lu\n", + if (ring->type == RING_TYPE_CH) { + mhi_log(MHI_MSG_VERBOSE, "TRE data buff ptr : 0x%llx\n", + el->tre.data_buf_ptr); + mhi_log(MHI_MSG_VERBOSE, "TRE len : 0x%x, rd_offset:%lu\n", el->tre.len, offset); + } if (ring->ring_cb) return ring->ring_cb(ring->mhi_dev, el, (void *)ring); @@ -209,13 +212,12 @@ EXPORT_SYMBOL(mhi_dev_process_ring_element); int mhi_dev_process_ring(struct mhi_dev_ring *ring) { int rc = 0; - union mhi_dev_ring_element_type *el; if (WARN_ON(!ring)) return -EINVAL; mhi_log(MHI_MSG_VERBOSE, - "Before wr update ring_id (%d) element (%lu) with wr:%lu\n", + "Before wr update ring_id (%d) rp:%lu wp:%lu\n", ring->id, ring->rd_offset, ring->wr_offset); rc = mhi_dev_update_wr_offset(ring); @@ -226,37 +228,36 @@ int mhi_dev_process_ring(struct mhi_dev_ring *ring) return rc; } - /* get the element and invoke the respective callback */ - el = &ring->ring_cache[ring->wr_offset]; - - mhi_log(MHI_MSG_VERBOSE, "evnt ptr : 0x%llx\n", el->tre.data_buf_ptr); - mhi_log(MHI_MSG_VERBOSE, "evnt len : 0x%x, wr_offset:%lu\n", - el->tre.len, ring->wr_offset); + mhi_log(MHI_MSG_VERBOSE, + "After wp update ring_id (%d) rp:%lu with wr:%lu\n", + ring->id, ring->rd_offset, ring->wr_offset); + /* + * Notify the clients that there are elements in the ring. + * For channels, simply notify client for the first element (no need to + * notify for all the elements) and return (no need to update rd + * pointer). When client consumes the elements, rp will be updated. + */ if (ring->type == RING_TYPE_CH) { - /* notify the clients that there are elements in the ring */ rc = mhi_dev_process_ring_element(ring, ring->rd_offset); if (rc) pr_err("Error fetching elements\n"); return rc; } - mhi_log(MHI_MSG_VERBOSE, - "After ring update ring_id (%d) element (%lu) with wr:%lu\n", - ring->id, ring->rd_offset, ring->wr_offset); while (ring->rd_offset != ring->wr_offset) { - rc = mhi_dev_process_ring_element(ring, ring->rd_offset); - if (rc) { - mhi_log(MHI_MSG_ERROR, - "Error processing ring (%d) element (%lu)\n", - ring->id, ring->rd_offset); - return rc; - } - mhi_log(MHI_MSG_VERBOSE, "Processing ring (%d) rd_offset:%lu, wr_offset:%lu\n", ring->id, ring->rd_offset, ring->wr_offset); + rc = mhi_dev_process_ring_element(ring, ring->rd_offset); + if (rc) { + mhi_log(MHI_MSG_ERROR, + "Error processing ring (%d) element(rp) (%lu)\n", + ring->id, ring->rd_offset); + return rc; + } + mhi_dev_ring_inc_index(ring, ring->rd_offset); } From 455fd0af3b1bdf8422db9ca3f2700e951efd294f Mon Sep 17 00:00:00 2001 From: Jyothi Kumar Seerapu Date: Tue, 22 Mar 2022 20:00:14 +0530 Subject: [PATCH 41/48] msm: mhi_dev: Clean up logs in mhi-dev driver Replace pr_err logs with mhi log support present in mhi-dev driver. Added separate buffer logging support for MHI IPC error logs. Change-Id: I10e39fabc8574ccfc507a8b1d34d25e9ab78265a Signed-off-by: Jyothi Kumar Seerapu --- drivers/platform/msm/mhi_dev/mhi.c | 357 +++++++++++++-------- drivers/platform/msm/mhi_dev/mhi.h | 8 +- drivers/platform/msm/mhi_dev/mhi_dev_net.c | 29 +- drivers/platform/msm/mhi_dev/mhi_mmio.c | 4 +- drivers/platform/msm/mhi_dev/mhi_ring.c | 23 +- drivers/platform/msm/mhi_dev/mhi_uci.c | 31 +- 6 files changed, 267 insertions(+), 185 deletions(-) diff --git a/drivers/platform/msm/mhi_dev/mhi.c b/drivers/platform/msm/mhi_dev/mhi.c index 99a7cca705ad..fa551f5ee600 100644 --- a/drivers/platform/msm/mhi_dev/mhi.c +++ b/drivers/platform/msm/mhi_dev/mhi.c @@ -57,6 +57,7 @@ #define HOST_ADDR_MSB(addr) ((addr >> 32) & 0xFFFFFFFF) #define MHI_IPC_LOG_PAGES (100) +#define MHI_IPC_ERR_LOG_PAGES (10) #define MHI_REGLEN 0x100 #define MHI_INIT 0 #define MHI_REINIT 1 @@ -71,7 +72,9 @@ uint32_t bhi_imgtxdb; enum mhi_msg_level mhi_msg_lvl = MHI_MSG_ERROR; enum mhi_msg_level mhi_ipc_msg_lvl = MHI_MSG_VERBOSE; +enum mhi_msg_level mhi_ipc_err_msg_lvl = MHI_MSG_ERROR; void *mhi_ipc_log; +void *mhi_ipc_err_log; static struct mhi_dev *mhi_ctx; static void mhi_hwc_cb(void *priv, enum ipa_mhi_event_type event, @@ -156,7 +159,8 @@ void mhi_dev_read_from_host_ipa(struct mhi_dev *mhi, struct mhi_addr *transfer) (int)transfer->size, mhi_dev_ring_cache_completion_cb, &ring_req); if (rc) - pr_err("error while reading from host:%d\n", rc); + mhi_log(MHI_MSG_ERROR, "error while reading from host:%d\n", + rc); wait_for_completion(&done); } @@ -226,7 +230,8 @@ void mhi_dev_write_to_host_ipa(struct mhi_dev *mhi, struct mhi_addr *transfer, (int)transfer->size, cb_func, ereq); if (rc) - pr_err("error while writing to host:%d\n", rc); + mhi_log(MHI_MSG_ERROR, + "error while writing to host:%d\n", rc); } else if (tr_type == MHI_DEV_DMA_SYNC) { /* Copy the device content to a local device * physical address. @@ -237,7 +242,8 @@ void mhi_dev_write_to_host_ipa(struct mhi_dev *mhi, struct mhi_addr *transfer, (u64) mhi->cache_dma_handle, (int) transfer->size); if (rc) - pr_err("error while writing to host:%d\n", rc); + mhi_log(MHI_MSG_ERROR, + "error while writing to host:%d\n", rc); } } @@ -276,7 +282,7 @@ static int mhi_dev_schedule_msi_ipa(struct mhi_dev *mhi, struct event_req *ereq) rc = ep_pcie_get_msi_config(mhi->phandle, &cfg); if (rc) { - pr_err("Error retrieving pcie msi logic\n"); + mhi_log(MHI_MSG_ERROR, "Error retrieving pcie msi logic\n"); return rc; } @@ -408,7 +414,8 @@ static int mhi_trigger_msi_edma(struct mhi_dev_ring *ring, u32 idx) if (!mhi_ctx->msi_lower) { rc = ep_pcie_get_msi_config(mhi_ctx->phandle, &cfg); if (rc) { - pr_err("Error retrieving pcie msi logic\n"); + mhi_log(MHI_MSG_ERROR, + "Error retrieving pcie msi logic\n"); return rc; } @@ -431,7 +438,8 @@ static int mhi_trigger_msi_edma(struct mhi_dev_ring *ring, u32 idx) sizeof(u32), DMA_PREP_INTERRUPT); if (!descriptor) { - pr_err("%s(): desc is null, MSI to Host failed\n", __func__); + mhi_log(MHI_MSG_ERROR, + "desc is null, MSI to Host failed\n"); spin_unlock_irqrestore(&mhi_ctx->msi_lock, flags); return -EFAULT; } @@ -457,17 +465,19 @@ static int mhi_dev_send_multiple_tr_events(struct mhi_dev *mhi, int evnt_ring, struct mhi_dev_channel *ch; if (!ereq) { - pr_err("%s(): invalid event req\n", __func__); + mhi_log(MHI_MSG_ERROR, "invalid event req\n"); return -EINVAL; } if (evnt_ring_idx > mhi->cfg.event_rings) { - pr_err("Invalid event ring idx: %lld\n", evnt_ring_idx); + mhi_log(MHI_MSG_ERROR, + "Invalid event ring idx: %lld\n", evnt_ring_idx); return -EINVAL; } if (!ring) { - pr_err("%s(): Ring %d not present\n", __func__, evnt_ring_idx); + mhi_log(MHI_MSG_ERROR, "Ring %d not present\n", + evnt_ring_idx); return -EINVAL; } @@ -518,7 +528,8 @@ static int mhi_dev_send_multiple_tr_events(struct mhi_dev *mhi, int evnt_ring, rc = mhi_dev_add_element(ring, ereq->tr_events, ereq, evt_len); if (rc) { - pr_err("%s(): error in adding element rc %d\n", __func__, rc); + mhi_log(MHI_MSG_ERROR, + "error in adding element rc %d\n", rc); goto exit; } @@ -560,12 +571,12 @@ static int mhi_dev_send_multiple_tr_events(struct mhi_dev *mhi, int evnt_ring, if (mhi_ctx->use_edma) { rc = mhi_trigger_msi_edma(ring, ctx->ev.msivec); if (rc) - pr_err("%s: error sending in msi\n", __func__); + mhi_log(MHI_MSG_ERROR, "error sending in msi\n"); } else { /* Schedule DMA for MSI*/ rc = mhi_dev_schedule_msi_ipa(mhi, ereq); if (rc) - pr_err("%s: error sending in msi\n", __func__); + mhi_log(MHI_MSG_ERROR, "error sending in msi\n"); } exit: @@ -663,8 +674,6 @@ static int mhi_dev_flush_transfer_completion_events(struct mhi_dev *mhi, if (flush_ereq->tr_events < ch->tr_events || (flush_ereq->tr_events + flush_ereq->num_events) > (ch->tr_events + ch->evt_buf_size)) { - pr_err("%s: Invalid completion event buffer!\n", - __func__); mhi_log(MHI_MSG_ERROR, "Invalid cmpl evt buf - start %pK, end %pK\n", flush_ereq->tr_events, @@ -800,7 +809,6 @@ static int mhi_dev_queue_transfer_completion(struct mhi_req *mreq, bool *flush) ch->curr_ereq->num_events = 0; ch->curr_ereq->start = ch->evt_buf_rp; } else { - pr_err("%s evt req buffers empty\n", __func__); mhi_log(MHI_MSG_ERROR, "evt req buffers empty\n"); ch->curr_ereq = NULL; @@ -848,7 +856,8 @@ int mhi_transfer_host_to_device_ipa(void *dev, uint64_t host_pa, uint32_t len, rc = ipa_dma_sync_memcpy((u64) mhi->read_dma_handle, host_addr_pa, (int) len); if (rc) { - pr_err("error while reading chan using sync:%d\n", rc); + mhi_log(MHI_MSG_ERROR, + "error while reading chan using sync:%d\n", rc); return rc; } memcpy(dev, mhi->read_handle, len); @@ -943,7 +952,8 @@ int mhi_transfer_device_to_host_ipa(uint64_t host_addr, void *dev, uint32_t len, /* Queue the completion event for the current transfer */ rc = mhi_dev_queue_transfer_completion(req, &flush); if (rc) { - pr_err("Failed to queue completion: %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Failed to queue completion: %d\n", rc); return rc; } @@ -1001,7 +1011,7 @@ void mhi_dev_read_from_host_edma(struct mhi_dev *mhi, struct mhi_addr *transfer) transfer->phy_addr, host_addr_pa, (int)transfer->size, DMA_PREP_INTERRUPT); if (!descriptor) { - pr_err("%s(): descriptor is null\n", __func__); + mhi_log(MHI_MSG_ERROR, "descriptor is null\n"); return; } descriptor->callback_param = &read_from_host; @@ -1052,7 +1062,8 @@ void mhi_dev_write_to_host_edma(struct mhi_dev *mhi, struct mhi_addr *transfer, transfer->virt_addr, transfer->size, DMA_TO_DEVICE); if (dma_mapping_error(&mhi->pdev->dev, dma)) { - pr_err("%s(): dma mapping failed\n", __func__); + mhi_log(MHI_MSG_ERROR, + "dma mapping failed\n"); return; } } @@ -1076,7 +1087,7 @@ void mhi_dev_write_to_host_edma(struct mhi_dev *mhi, struct mhi_addr *transfer, dma, (int)transfer->size, DMA_PREP_INTERRUPT); if (!descriptor) { - pr_err("%s(): descriptor is null\n", __func__); + mhi_log(MHI_MSG_ERROR, "descriptor is null\n"); dma_unmap_single(&mhi->pdev->dev, (size_t)transfer->virt_addr, transfer->size, DMA_TO_DEVICE); @@ -1097,7 +1108,7 @@ void mhi_dev_write_to_host_edma(struct mhi_dev *mhi, struct mhi_addr *transfer, (int)transfer->size, DMA_PREP_INTERRUPT); if (!descriptor) { - pr_err("%s(): descriptor is null\n", __func__); + mhi_log(MHI_MSG_ERROR, "descriptor is null\n"); return; } @@ -1148,7 +1159,7 @@ int mhi_transfer_host_to_device_edma(void *dev, uint64_t host_pa, uint32_t len, host_addr_pa, (int)len, DMA_PREP_INTERRUPT); if (!descriptor) { - pr_err("%s(): descriptor is null\n", __func__); + mhi_log(MHI_MSG_ERROR, "descriptor is null\n"); return -EFAULT; } descriptor->callback_param = &transfer_host_to_device; @@ -1168,7 +1179,7 @@ int mhi_transfer_host_to_device_edma(void *dev, uint64_t host_pa, uint32_t len, mreq->dma = dma_map_single(&mhi->pdev->dev, dev, len, DMA_FROM_DEVICE); if (dma_mapping_error(&mhi->pdev->dev, mreq->dma)) { - pr_err("%s(): dma map single failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "dma map single failed\n"); return -ENOMEM; } @@ -1183,7 +1194,8 @@ int mhi_transfer_host_to_device_edma(void *dev, uint64_t host_pa, uint32_t len, /* Queue the completion event for the current transfer */ rc = mhi_dev_queue_transfer_completion(mreq, NULL); if (rc) { - pr_err("Failed to queue completion: %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Failed to queue completion: %d\n", rc); return rc; } @@ -1192,7 +1204,7 @@ int mhi_transfer_host_to_device_edma(void *dev, uint64_t host_pa, uint32_t len, host_addr_pa, (int)len, DMA_PREP_INTERRUPT); if (!descriptor) { - pr_err("%s(): descriptor is null\n", __func__); + mhi_log(MHI_MSG_ERROR, "descriptor is null\n"); /* Roll back the completion event that we wrote above */ mhi_dev_rollback_compl_evt(ch); dma_unmap_single(&mhi->pdev->dev, (size_t)dev, len, @@ -1244,7 +1256,7 @@ int mhi_transfer_device_to_host_edma(uint64_t host_addr, void *dev, host_addr_pa, mhi->write_dma_handle, (int)len, DMA_PREP_INTERRUPT); if (!descriptor) { - pr_err("%s(): descriptor is null\n", __func__); + mhi_log(MHI_MSG_ERROR, "descriptor is null\n"); return -EFAULT; } descriptor->callback_param = &transfer_device_to_host; @@ -1262,7 +1274,7 @@ int mhi_transfer_device_to_host_edma(uint64_t host_addr, void *dev, req->dma = dma_map_single(&mhi->pdev->dev, req->buf, req->len, DMA_TO_DEVICE); if (dma_mapping_error(&mhi->pdev->dev, req->dma)) { - pr_err("%s(): dma map single failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "dma map single failed\n"); return -ENOMEM; } @@ -1274,7 +1286,8 @@ int mhi_transfer_device_to_host_edma(uint64_t host_addr, void *dev, /* Queue the completion event for the current transfer */ rc = mhi_dev_queue_transfer_completion(req, &flush); if (rc) { - pr_err("Failed to queue completion: %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Failed to queue completion: %d\n", rc); return rc; } @@ -1282,7 +1295,7 @@ int mhi_transfer_device_to_host_edma(uint64_t host_addr, void *dev, host_addr_pa, req->dma, (int) len, DMA_PREP_INTERRUPT); if (!descriptor) { - pr_err("%s(): descriptor is null\n", __func__); + mhi_log(MHI_MSG_ERROR, "descriptor is null\n"); /* Roll back the completion event that we wrote above */ mhi_dev_rollback_compl_evt(ch); /* Unmap the buffer */ @@ -1364,13 +1377,15 @@ static int mhi_enable_int(void) rc = mhi_dev_mmio_enable_ctrl_interrupt(mhi_ctx); if (rc) { - pr_err("Failed to enable control interrupt: %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Failed to enable control interrupt: %d\n", rc); return rc; } rc = mhi_dev_mmio_enable_cmdb_interrupt(mhi_ctx); if (rc) { - pr_err("Failed to enable command db: %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Failed to enable command db: %d\n", rc); return rc; } mhi_update_state_info(MHI_STATE_CONNECTED); @@ -1395,20 +1410,22 @@ static int mhi_hwc_init(struct mhi_dev *mhi) */ rc = mhi_enable_int(); if (rc) - pr_err("Error configuring interrupts: rc = %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Error configuring interrupts: rc = %d\n", rc); return rc; } /* Call IPA HW_ACC Init with MSI Address and db routing info */ rc = ep_pcie_get_msi_config(mhi_ctx->phandle, &cfg); if (rc) { - pr_err("Error retrieving pcie msi logic\n"); + mhi_log(MHI_MSG_ERROR, + "Error retrieving pcie msi logic\n"); return rc; } rc = mhi_pcie_config_db_routing(mhi); if (rc) { - pr_err("Error configuring DB routing\n"); + mhi_log(MHI_MSG_ERROR, "Error configuring DB routing\n"); return rc; } @@ -1475,13 +1492,15 @@ static void mhi_hwc_cb(void *priv, enum ipa_mhi_event_type event, "HW Channel uC is ready event=0x%X\n", event); rc = mhi_hwc_start(mhi_ctx); if (rc) { - pr_err("hwc_init start failed with %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "hwc_init start failed with %d\n", rc); return; } rc = mhi_enable_int(); if (rc) { - pr_err("Error configuring interrupts, rc = %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Error configuring interrupts, rc = %d\n", rc); return; } @@ -1490,12 +1509,14 @@ static void mhi_hwc_cb(void *priv, enum ipa_mhi_event_type event, case IPA_MHI_EVENT_DATA_AVAILABLE: rc = mhi_dev_notify_sm_event(MHI_DEV_EVENT_HW_ACC_WAKEUP); if (rc) { - pr_err("Event HW_ACC_WAKEUP failed with %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Event HW_ACC_WAKEUP failed with %d\n", rc); return; } break; default: - pr_err("HW Channel uC unknown event 0x%X\n", event); + mhi_log(MHI_MSG_ERROR, + "HW Channel uC unknown event 0x%X\n", event); break; } } @@ -1512,14 +1533,16 @@ static int mhi_hwc_chcmd(struct mhi_dev *mhi, uint chid, case MHI_DEV_RING_EL_RESET: case MHI_DEV_RING_EL_STOP: if ((chid-HW_CHANNEL_BASE) > NUM_HW_CHANNELS) { - pr_err("Invalid Channel ID = 0x%X\n", chid); + mhi_log(MHI_MSG_ERROR, + "Invalid Channel ID = 0x%X\n", chid); return -EINVAL; } rc = ipa_mhi_disconnect_pipe( mhi->ipa_clnt_hndl[chid-HW_CHANNEL_BASE]); if (rc) - pr_err("Stopping HW Channel%d failed 0x%X\n", + mhi_log(MHI_MSG_ERROR, + "Stopping HW Channel%d failed 0x%X\n", chid, rc); break; case MHI_DEV_RING_EL_START: @@ -1527,24 +1550,28 @@ static int mhi_hwc_chcmd(struct mhi_dev *mhi, uint chid, connect_params.sys.skip_ep_cfg = true; if (chid > HW_CHANNEL_END) { - pr_err("Channel DB for %d not enabled\n", chid); + mhi_log(MHI_MSG_ERROR, + "Channel DB for %d not enabled\n", chid); return -EINVAL; } if ((chid-HW_CHANNEL_BASE) > NUM_HW_CHANNELS) { - pr_err("Invalid Channel = 0x%X\n", chid); + mhi_log(MHI_MSG_ERROR, + "Invalid Channel = 0x%X\n", chid); return -EINVAL; } rc = ipa_mhi_connect_pipe(&connect_params, &mhi->ipa_clnt_hndl[chid-HW_CHANNEL_BASE]); if (rc) - pr_err("HW Channel%d start failed : %d\n", + mhi_log(MHI_MSG_ERROR, + "HW Channel%d start failed : %d\n", chid, rc); break; case MHI_DEV_RING_EL_INVALID: default: - pr_err("Invalid Ring Element type = 0x%X\n", type); + mhi_log(MHI_MSG_ERROR, + "Invalid Ring Element type = 0x%X\n", type); break; } @@ -1558,13 +1585,13 @@ static void mhi_dev_core_ack_ctrl_interrupts(struct mhi_dev *dev, rc = mhi_dev_mmio_read(dev, MHI_CTRL_INT_STATUS_A7, int_value); if (rc) { - pr_err("Failed to read A7 status\n"); + mhi_log(MHI_MSG_ERROR, "Failed to read A7 status\n"); return; } rc = mhi_dev_mmio_write(dev, MHI_CTRL_INT_CLEAR_A7, *int_value); if (rc) { - pr_err("Failed to clear A7 status\n"); + mhi_log(MHI_MSG_ERROR, "Failed to clear A7 status\n"); return; } } @@ -1590,7 +1617,7 @@ int mhi_dev_syserr(struct mhi_dev *mhi) if (WARN_ON(!mhi)) return -EINVAL; - pr_err("MHI dev sys error\n"); + mhi_log(MHI_MSG_ERROR, "MHI dev sys error\n"); return mhi_dev_dump_mmio(mhi); } @@ -1608,12 +1635,13 @@ int mhi_dev_send_event(struct mhi_dev *mhi, int evnt_ring, rc = ep_pcie_get_msi_config(mhi->phandle, &cfg); if (rc) { - pr_err("Error retrieving pcie msi logic\n"); + mhi_log(MHI_MSG_ERROR, "Error retrieving pcie msi logic\n"); return rc; } if (evnt_ring_idx > mhi->cfg.event_rings) { - pr_err("Invalid event ring idx: %lld\n", evnt_ring_idx); + mhi_log(MHI_MSG_ERROR, + "Invalid event ring idx: %lld\n", evnt_ring_idx); return -EINVAL; } @@ -1900,7 +1928,8 @@ static void mhi_dev_process_reset_cmd(struct mhi_dev *mhi, int ch_id) rc = mhi_dev_send_cmd_comp_event(mhi, MHI_CMD_COMPL_CODE_SUCCESS); if (rc) - pr_err("Error sending command completion event\n"); + mhi_log(MHI_MSG_ERROR, + "Error sending command completion event\n"); ch->reset_pending = false; } @@ -2004,7 +2033,8 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, rc = mhi_dev_send_cmd_comp_event(mhi, MHI_CMD_COMPL_CODE_SUCCESS); if (rc) - pr_err("Error sending command completion event\n"); + mhi_log(MHI_MSG_ERROR, + "Error sending command completion event\n"); mhi_update_state_info_ch(ch_id, MHI_STATE_CONNECTED); /* Trigger callback to clients */ @@ -2047,7 +2077,8 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, rc = mhi_dev_flush_cmd_completion_events(mhi, &event); if (rc) { - pr_err("stop event send failed\n"); + mhi_log(MHI_MSG_ERROR, + "stop event send failed\n"); return rc; } } else { @@ -2060,7 +2091,8 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, */ ring = &mhi->ring[ch_id + mhi->ch_ring_start]; if (ring->state == RING_STATE_UINT) { - pr_err("Channel not opened for %d\n", ch_id); + mhi_log(MHI_MSG_ERROR, + "Channel not opened for %d\n", ch_id); return -EINVAL; } @@ -2074,7 +2106,8 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, &mhi->ring[mhi->ch_ring_start + ch_id], ch_id, mhi); if (rc) - pr_err("stop event send failed\n"); + mhi_log(MHI_MSG_ERROR, + "stop event send failed\n"); mutex_unlock(&ch->ring->event_lock); mutex_unlock(&ch->ch_lock); @@ -2109,7 +2142,8 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, rc = mhi_dev_flush_cmd_completion_events(mhi, &event); if (rc) { - pr_err("stop event send failed\n"); + mhi_log(MHI_MSG_ERROR, + "stop event send failed\n"); return rc; } } else { @@ -2120,7 +2154,8 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, ring = &mhi->ring[ch_id + mhi->ch_ring_start]; if (ring->state == RING_STATE_UINT) { - pr_err("Channel not opened for %d\n", ch_id); + mhi_log(MHI_MSG_ERROR, + "Channel not opened for %d\n", ch_id); return -EINVAL; } ch = &mhi->ch[ch_id]; @@ -2146,7 +2181,8 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, } break; default: - pr_err("%s: Invalid command:%d\n", __func__, el->generic.type); + mhi_log(MHI_MSG_ERROR, + "Invalid command:%d\n", el->generic.type); break; } return rc; @@ -2301,7 +2337,8 @@ static bool mhi_dev_queue_channel_db(struct mhi_dev *mhi, mutex_unlock(&ch->ch_lock); rc = mhi_dev_mmio_disable_chdb_a7(mhi, ch_num); if (rc) { - pr_err("Error disabling chdb\n"); + mhi_log(MHI_MSG_ERROR, + "Error disabling chdb\n"); return work_pending; } } @@ -2404,25 +2441,28 @@ static int mhi_dev_abort(struct mhi_dev *mhi) /* Clean up initialized channels */ rc = mhi_deinit(mhi); if (rc) { - pr_err("Error during mhi_deinit with %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Error during mhi_deinit with %d\n", rc); return rc; } rc = mhi_dev_mmio_mask_chdb_interrupts(mhi_ctx); if (rc) { - pr_err("Failed to enable channel db\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to enable channel db\n"); return rc; } rc = mhi_dev_mmio_disable_ctrl_interrupt(mhi_ctx); if (rc) { - pr_err("Failed to enable control interrupt\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to enable control interrupt\n"); return rc; } rc = mhi_dev_mmio_disable_cmdb_interrupt(mhi_ctx); if (rc) { - pr_err("Failed to enable command db\n"); + mhi_log(MHI_MSG_ERROR, "Failed to enable command db\n"); return rc; } @@ -2440,7 +2480,8 @@ static int mhi_dev_abort(struct mhi_dev *mhi) rc = ep_pcie_register_event(mhi_ctx->phandle, &mhi_ctx->event_reg); if (rc) { - pr_err("Failed to register for events from PCIe\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to register for events from PCIe\n"); return rc; } @@ -2534,7 +2575,7 @@ static void mhi_dev_scheduler(struct work_struct *work) rc = mhi_dev_mmio_get_mhi_state(mhi, &state, &mhi_reset); if (rc) { - pr_err("%s: get mhi state failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "get mhi state failed\n"); mutex_unlock(&mhi_ctx->mhi_lock); return; } @@ -2544,7 +2585,8 @@ static void mhi_dev_scheduler(struct work_struct *work) "processing mhi device reset\n"); rc = mhi_dev_abort(mhi); if (rc) - pr_err("device reset failed:%d\n", rc); + mhi_log(MHI_MSG_ERROR, + "device reset failed:%d\n", rc); mutex_unlock(&mhi_ctx->mhi_lock); queue_work(mhi->ring_init_wq, &mhi->re_init); return; @@ -2552,13 +2594,14 @@ static void mhi_dev_scheduler(struct work_struct *work) rc = mhi_dev_get_event_notify(state, &event); if (rc) { - pr_err("unsupported state :%d\n", state); + mhi_log(MHI_MSG_ERROR, + "unsupported state :%d\n", state); goto fail; } rc = mhi_dev_notify_sm_event(event); if (rc) { - pr_err("error sending SM event\n"); + mhi_log(MHI_MSG_ERROR, "error sending SM event\n"); goto fail; } } @@ -2681,7 +2724,8 @@ static int mhi_dev_cache_host_cfg(struct mhi_dev *mhi) mhi->ctrl_base.device_pa, mhi->ctrl_base.size); if (!mhi->ctrl_base.device_va) { - pr_err("io remap failed for mhi address\n"); + mhi_log(MHI_MSG_ERROR, + "io remap failed for mhi address\n"); return -EINVAL; } } @@ -2690,7 +2734,7 @@ static int mhi_dev_cache_host_cfg(struct mhi_dev *mhi) if (mhi->config_iatu) { rc = mhi_dev_config_outbound_iatu(mhi); if (rc) { - pr_err("Configuring iATU failed\n"); + mhi_log(MHI_MSG_ERROR, "Configuring iATU failed\n"); return rc; } } @@ -2698,25 +2742,25 @@ static int mhi_dev_cache_host_cfg(struct mhi_dev *mhi) /* Get Channel, event and command context base pointer */ rc = mhi_dev_mmio_get_chc_base(mhi); if (rc) { - pr_err("Fetching channel context failed\n"); + mhi_log(MHI_MSG_ERROR, "Fetching channel context failed\n"); return rc; } rc = mhi_dev_mmio_get_erc_base(mhi); if (rc) { - pr_err("Fetching event ring context failed\n"); + mhi_log(MHI_MSG_ERROR, "Fetching event ring context failed\n"); return rc; } rc = mhi_dev_mmio_get_crc_base(mhi); if (rc) { - pr_err("Fetching command ring context failed\n"); + mhi_log(MHI_MSG_ERROR, "Fetching command ring context failed\n"); return rc; } rc = mhi_dev_update_ner(mhi); if (rc) { - pr_err("Fetching NER failed\n"); + mhi_log(MHI_MSG_ERROR, "Fetching NER failed\n"); return rc; } @@ -2761,7 +2805,8 @@ static int mhi_dev_cache_host_cfg(struct mhi_dev *mhi) &mhi->cmd_ctx_cache_dma_handle, GFP_KERNEL); if (!mhi->cmd_ctx_cache) { - pr_err("no memory while allocating cmd ctx\n"); + mhi_log(MHI_MSG_ERROR, + "no memory while allocating cmd ctx\n"); rc = -ENOMEM; goto exit; } @@ -2834,7 +2879,7 @@ static int mhi_dev_cache_host_cfg(struct mhi_dev *mhi) rc = mhi_ring_start(&mhi->ring[0], (union mhi_dev_ring_ctx *)mhi->cmd_ctx_cache, mhi); if (rc) { - pr_err("MHI ring start failed:%d\n", rc); + mhi_log(MHI_MSG_ERROR, "MHI ring start failed:%d\n", rc); goto exit; } @@ -3350,7 +3395,8 @@ int mhi_dev_read_channel(struct mhi_req *mreq) return -ENXIO; if (mhi_ctx->ctrl_info != MHI_STATE_CONNECTED) { - pr_err("Channel not connected:%d\n", mhi_ctx->ctrl_info); + mhi_log(MHI_MSG_ERROR, + "Channel not connected:%d\n", mhi_ctx->ctrl_info); return -ENODEV; } @@ -3501,12 +3547,14 @@ int mhi_dev_write_channel(struct mhi_req *wreq) enum mhi_ctrl_info info; if (WARN_ON(!wreq || !wreq->client || !wreq->buf)) { - pr_err("%s: invalid parameters\n", __func__); + mhi_log(MHI_MSG_ERROR, + "invalid parameters\n"); return -ENXIO; } if (mhi_ctx->ctrl_info != MHI_STATE_CONNECTED) { - pr_err("Channel not connected:%d\n", mhi_ctx->ctrl_info); + mhi_log(MHI_MSG_ERROR, + "Channel not connected:%d\n", mhi_ctx->ctrl_info); return -ENODEV; } @@ -3524,7 +3572,8 @@ int mhi_dev_write_channel(struct mhi_req *wreq) mhi_log(MHI_MSG_CRITICAL, "Wakeup by chan:%d\n", ch->ch_id); rc = mhi_dev_notify_sm_event(MHI_DEV_EVENT_CORE_WAKEUP); if (rc) { - pr_err("error sending core wakeup event\n"); + mhi_log(MHI_MSG_ERROR, + "error sending core wakeup event\n"); mutex_unlock(&mhi_ctx->mhi_lock); mutex_unlock(&mhi_ctx->mhi_write_test); return rc; @@ -3541,7 +3590,7 @@ int mhi_dev_write_channel(struct mhi_req *wreq) if (suspend_wait_timeout >= MHI_WAKEUP_TIMEOUT_CNT || mhi_ctx->ctrl_info != MHI_STATE_CONNECTED) { - pr_err("Failed to wake up core\n"); + mhi_log(MHI_MSG_ERROR, "Failed to wake up core\n"); mutex_unlock(&mhi_ctx->mhi_write_test); return -ENODEV; } @@ -3581,8 +3630,8 @@ int mhi_dev_write_channel(struct mhi_req *wreq) do { if (ring->rd_offset == ring->wr_offset) { mhi_log(MHI_MSG_ERROR, - "%s():rd & wr offsets are equal\n", - __func__); + "rd & wr offsets are equal for channel-id %d\n", + wreq->chan); mhi_log(MHI_MSG_INFO, "No TREs available\n"); break; } @@ -3590,8 +3639,9 @@ int mhi_dev_write_channel(struct mhi_req *wreq) el = &ring->ring_cache[ring->rd_offset]; tre_len = el->tre.len; if (wreq->len > tre_len) { - pr_err("%s(): rlen = %lu, tlen = %d: client buf > tre len\n", - __func__, wreq->len, tre_len); + mhi_log(MHI_MSG_ERROR, + "rlen = %lu, tlen = %d: client buf > tre len\n", + wreq->len, tre_len); bytes_written = -ENOMEM; goto exit; } @@ -3679,7 +3729,8 @@ static int mhi_dev_recover(struct mhi_dev *mhi) /* Poll for the host to set the reset bit */ rc = mhi_dev_mmio_get_mhi_state(mhi, &state, &mhi_reset); if (rc) { - pr_err("%s: get mhi state failed\n", __func__); + mhi_log(MHI_MSG_ERROR, + "get mhi state failed\n"); return rc; } @@ -3698,7 +3749,8 @@ static int mhi_dev_recover(struct mhi_dev *mhi) "Wait for Host to set BHI_INTVEC\n"); rc = mhi_dev_mmio_read(mhi, BHI_INTVEC, &bhi_intvec); if (rc) { - pr_err("%s: Get BHI_INTVEC failed\n", __func__); + mhi_log(MHI_MSG_ERROR, + "Get BHI_INTVEC failed\n"); return rc; } bhi_max_cnt++; @@ -3714,7 +3766,7 @@ static int mhi_dev_recover(struct mhi_dev *mhi) /* Indicate the host that the device is ready */ rc = ep_pcie_trigger_msi(mhi->phandle, bhi_intvec); if (rc) { - pr_err("%s: error sending msi\n", __func__); + mhi_log(MHI_MSG_ERROR, "error sending msi\n"); return rc; } } @@ -3722,7 +3774,7 @@ static int mhi_dev_recover(struct mhi_dev *mhi) /* Poll for the host to set the reset bit */ rc = mhi_dev_mmio_get_mhi_state(mhi, &state, &mhi_reset); if (rc) { - pr_err("%s: get mhi state failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "get mhi state failed\n"); return rc; } @@ -3735,7 +3787,8 @@ static int mhi_dev_recover(struct mhi_dev *mhi) rc = mhi_dev_mmio_get_mhi_state(mhi, &state, &mhi_reset); if (rc) { - pr_err("%s: get mhi state failed\n", __func__); + mhi_log(MHI_MSG_ERROR, + "get mhi state failed\n"); return rc; } max_cnt++; @@ -3766,20 +3819,20 @@ static void mhi_dev_enable(struct work_struct *work) if (mhi->use_ipa) { rc = ipa_dma_init(); if (rc) { - pr_err("ipa dma init failed\n"); + mhi_log(MHI_MSG_ERROR, "ipa dma init failed\n"); return; } rc = ipa_dma_enable(); if (rc) { - pr_err("ipa enable failed\n"); + mhi_log(MHI_MSG_ERROR, "ipa enable failed\n"); return; } } rc = mhi_dev_mmio_get_mhi_state(mhi, &state, &mhi_reset); if (rc) { - pr_err("%s: get mhi state failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "get mhi state failed\n"); return; } if (mhi_reset) { @@ -3794,7 +3847,7 @@ static void mhi_dev_enable(struct work_struct *work) msleep(MHI_SUSPEND_MIN); rc = mhi_dev_mmio_get_mhi_state(mhi, &state, &mhi_reset); if (rc) { - pr_err("%s: get mhi state failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "get mhi state failed\n"); return; } if (mhi_reset) { @@ -3810,23 +3863,24 @@ static void mhi_dev_enable(struct work_struct *work) if (state == MHI_DEV_M0_STATE) { rc = mhi_dev_cache_host_cfg(mhi); if (rc) { - pr_err("Failed to cache the host config\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to cache the host config\n"); return; } rc = mhi_dev_mmio_set_env(mhi, MHI_ENV_VALUE); if (rc) { - pr_err("%s: env setting failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "env setting failed\n"); return; } } else { - pr_err("MHI device failed to enter M0\n"); + mhi_log(MHI_MSG_ERROR, "MHI device failed to enter M0\n"); return; } rc = mhi_hwc_init(mhi_ctx); if (rc) { - pr_err("error during hwc_init\n"); + mhi_log(MHI_MSG_ERROR, "error during hwc_init\n"); return; } @@ -3847,7 +3901,8 @@ static void mhi_dev_enable(struct work_struct *work) /*Enable MHI dev network stack Interface*/ rc = mhi_dev_net_interface_init(); if (rc) - pr_err("%s Failed to initialize mhi_dev_net iface\n", __func__); + mhi_log(MHI_MSG_ERROR, + "Failed to initialize mhi_dev_net iface\n"); } static void mhi_ring_init_cb(void *data) @@ -3870,7 +3925,7 @@ int mhi_register_state_cb(void (*mhi_state_cb) return -ENXIO; if (channel >= MHI_MAX_SOFTWARE_CHANNELS) { - pr_err("Invalid channel :%d\n", channel); + mhi_log(MHI_MSG_ERROR, "Invalid channel :%d\n", channel); return -EINVAL; } @@ -3959,14 +4014,16 @@ static int get_device_tree_data(struct platform_device *pdev) res_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mhi_mmio_base"); if (!res_mem) { - pr_err("Request MHI MMIO physical memory region failed\n"); + mhi_log(MHI_MSG_ERROR, + "Request MHI MMIO physical memory region failed\n"); return -EINVAL; } mhi->mmio_base_pa_addr = res_mem->start; mhi->mmio_base_addr = ioremap_nocache(res_mem->start, MHI_1K_SIZE); if (!mhi->mmio_base_addr) { - pr_err("Failed to IO map MMIO registers\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to IO map MMIO registers\n"); return -EINVAL; } @@ -3976,7 +4033,8 @@ static int get_device_tree_data(struct platform_device *pdev) res_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ipa_uc_mbox_crdb"); if (!res_mem) { - pr_err("Request IPA_UC_MBOX CRDB physical region failed\n"); + mhi_log(MHI_MSG_ERROR, + "Request IPA_UC_MBOX CRDB physical region failed\n"); rc = -EINVAL; goto err; } @@ -3986,7 +4044,8 @@ static int get_device_tree_data(struct platform_device *pdev) res_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ipa_uc_mbox_erdb"); if (!res_mem) { - pr_err("Request IPA_UC_MBOX ERDB physical region failed\n"); + mhi_log(MHI_MSG_ERROR, + "Request IPA_UC_MBOX ERDB physical region failed\n"); rc = -EINVAL; goto err; } @@ -4000,7 +4059,7 @@ static int get_device_tree_data(struct platform_device *pdev) "qcom,mhi-ifc-id", &mhi_ctx->ifc_id); if (rc) { - pr_err("qcom,mhi-ifc-id does not exist\n"); + mhi_log(MHI_MSG_ERROR, "qcom,mhi-ifc-id does not exist\n"); goto err; } @@ -4008,7 +4067,7 @@ static int get_device_tree_data(struct platform_device *pdev) "qcom,mhi-ep-msi", &mhi_ctx->mhi_ep_msi_num); if (rc) { - pr_err("qcom,mhi-ep-msi does not exist\n"); + mhi_log(MHI_MSG_ERROR, "qcom,mhi-ep-msi does not exist\n"); goto err; } @@ -4016,7 +4075,8 @@ static int get_device_tree_data(struct platform_device *pdev) "qcom,mhi-version", &mhi_ctx->mhi_version); if (rc) { - pr_err("qcom,mhi-version does not exist\n"); + mhi_log(MHI_MSG_ERROR, + "qcom,mhi-version does not exist\n"); goto err; } @@ -4031,7 +4091,8 @@ static int get_device_tree_data(struct platform_device *pdev) "qcom,mhi-local-pa-base", &mhi_ctx->device_local_pa_base); if (rc) { - pr_err("qcom,mhi-local-pa-base does not exist\n"); + mhi_log(MHI_MSG_ERROR, + "qcom,mhi-local-pa-base does not exist\n"); goto err; } } @@ -4042,7 +4103,8 @@ static int get_device_tree_data(struct platform_device *pdev) if (mhi->config_iatu || mhi_ctx->mhi_int) { mhi->mhi_irq = platform_get_irq_byname(pdev, "mhi-device-inta"); if (mhi->mhi_irq < 0) { - pr_err("Invalid MHI device interrupt\n"); + mhi_log(MHI_MSG_ERROR, + "Invalid MHI device interrupt\n"); rc = mhi->mhi_irq; goto err; } @@ -4086,7 +4148,8 @@ static int mhi_init(struct mhi_dev *mhi) rc = mhi_dev_mmio_init(mhi); if (rc) { - pr_err("Failed to update the MMIO init\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to update the MMIO init\n"); return rc; } @@ -4134,7 +4197,8 @@ static int mhi_dev_resume_mmio_mhi_reinit(struct mhi_dev *mhi_ctx) rc = mhi_init(mhi_ctx); if (rc) { - pr_err("Error initializing MHI MMIO with %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Error initializing MHI MMIO with %d\n", rc); goto fail; } @@ -4153,7 +4217,8 @@ static int mhi_dev_resume_mmio_mhi_reinit(struct mhi_dev *mhi_ctx) rc = ep_pcie_register_event(mhi_ctx->phandle, &mhi_ctx->event_reg); if (rc) { - pr_err("Failed to register for events from PCIe\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to register for events from PCIe\n"); goto fail; } @@ -4163,7 +4228,8 @@ static int mhi_dev_resume_mmio_mhi_reinit(struct mhi_dev *mhi_ctx) if (rc == -EEXIST) { mhi_ring_init_cb(mhi_ctx); } else { - pr_err("Error calling IPA cb with %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Error calling IPA cb with %d\n", rc); goto fail; } } @@ -4172,21 +4238,22 @@ static int mhi_dev_resume_mmio_mhi_reinit(struct mhi_dev *mhi_ctx) /* Invoke MHI SM when device is in RESET state */ rc = mhi_dev_sm_init(mhi_ctx); if (rc) { - pr_err("%s: Error during SM init\n", __func__); + mhi_log(MHI_MSG_ERROR, "Error during SM init\n"); goto fail; } /* set the env before setting the ready bit */ rc = mhi_dev_mmio_set_env(mhi_ctx, MHI_ENV_VALUE); if (rc) { - pr_err("%s: env setting failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "env setting failed\n"); goto fail; } /* All set, notify the host */ rc = mhi_dev_sm_set_ready(); if (rc) { - pr_err("%s: unable to set ready bit\n", __func__); + mhi_log(MHI_MSG_ERROR, + "unable to set ready bit\n"); goto fail; } @@ -4212,7 +4279,8 @@ static void mhi_dev_reinit(struct work_struct *work) /* PCIe link is up with BME set */ rc = mhi_dev_resume_mmio_mhi_reinit(mhi_ctx); if (rc) { - pr_err("Failed to register for events from PCIe\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to register for events from PCIe\n"); return; } } @@ -4265,13 +4333,14 @@ static int mhi_dev_resume_mmio_mhi_init(struct mhi_dev *mhi_ctx) mhi_ctx->phandle = ep_pcie_get_phandle(mhi_ctx->ifc_id); if (!mhi_ctx->phandle) { - pr_err("PCIe driver get handle failed.\n"); + mhi_log(MHI_MSG_ERROR, + "PCIe driver get handle failed.\n"); return -EINVAL; } rc = mhi_dev_recover(mhi_ctx); if (rc) { - pr_err("%s: get mhi state failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "get mhi state failed\n"); return rc; } @@ -4301,7 +4370,8 @@ static int mhi_dev_resume_mmio_mhi_init(struct mhi_dev *mhi_ctx) rc = mhi_dev_mmio_write(mhi_ctx, MHIVER, mhi_ctx->mhi_version); if (rc) { - pr_err("Failed to update the MHI version\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to update the MHI version\n"); return rc; } mhi_ctx->event_reg.events = EP_PCIE_EVENT_PM_D3_HOT | @@ -4319,19 +4389,21 @@ static int mhi_dev_resume_mmio_mhi_init(struct mhi_dev *mhi_ctx) rc = ep_pcie_register_event(mhi_ctx->phandle, &mhi_ctx->event_reg); if (rc) { - pr_err("Failed to register for events from PCIe\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to register for events from PCIe\n"); return rc; } if (mhi_ctx->use_ipa) { - pr_err("Registering with IPA\n"); + mhi_log(MHI_MSG_ERROR, "Registering with IPA\n"); rc = ipa_register_ipa_ready_cb(mhi_ring_init_cb, mhi_ctx); if (rc < 0) { if (rc == -EEXIST) { mhi_ring_init_cb(mhi_ctx); } else { - pr_err("Error calling IPA cb with %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Error calling IPA cb with %d\n", rc); return rc; } } @@ -4340,14 +4412,14 @@ static int mhi_dev_resume_mmio_mhi_init(struct mhi_dev *mhi_ctx) /* Invoke MHI SM when device is in RESET state */ rc = mhi_dev_sm_init(mhi_ctx); if (rc) { - pr_err("%s: Error during SM init\n", __func__); + mhi_log(MHI_MSG_ERROR, "Error during SM init\n"); return rc; } /* set the env before setting the ready bit */ rc = mhi_dev_mmio_set_env(mhi_ctx, MHI_ENV_VALUE); if (rc) { - pr_err("%s: env setting failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "env setting failed\n"); return rc; } @@ -4376,7 +4448,7 @@ static int mhi_dev_resume_mmio_mhi_init(struct mhi_dev *mhi_ctx) static void mhi_dev_resume_init_with_link_up(struct ep_pcie_notify *notify) { if (!notify || !notify->user) { - pr_err("Null argument for notify\n"); + mhi_log(MHI_MSG_ERROR, "Null argument for notify\n"); return; } @@ -4396,13 +4468,15 @@ static void mhi_dev_pcie_handle_event(struct work_struct *work) if (mhi_dev_pcie_notify_event == MHI_INIT) { rc = mhi_dev_resume_mmio_mhi_init(mhi_ctx); if (rc) { - pr_err("Error during MHI device initialization\n"); + mhi_log(MHI_MSG_ERROR, + "Error during MHI device initialization\n"); return; } } else if (mhi_dev_pcie_notify_event == MHI_REINIT) { rc = mhi_dev_resume_mmio_mhi_reinit(mhi_ctx); if (rc) { - pr_err("Error during MHI device re-initialization\n"); + mhi_log(MHI_MSG_ERROR, + "Error during MHI device re-initialization\n"); return; } } @@ -4412,7 +4486,8 @@ static int mhi_edma_init(struct device *dev) { mhi_ctx->tx_dma_chan = dma_request_slave_channel(dev, "tx"); if (IS_ERR_OR_NULL(mhi_ctx->tx_dma_chan)) { - pr_err("%s(): request for TX chan failed\n", __func__); + mhi_log(MHI_MSG_ERROR, + "request for TX chan failed\n"); return -EIO; } @@ -4421,7 +4496,8 @@ static int mhi_edma_init(struct device *dev) mhi_ctx->rx_dma_chan = dma_request_slave_channel(dev, "rx"); if (IS_ERR_OR_NULL(mhi_ctx->rx_dma_chan)) { - pr_err("%s(): request for RX chan failed\n", __func__); + mhi_log(MHI_MSG_ERROR, + "request for RX chan failed\n"); return -EIO; } mhi_log(MHI_MSG_VERBOSE, "request for RX chan returned :%pK\n", @@ -4436,7 +4512,8 @@ static int mhi_dev_probe(struct platform_device *pdev) if (pdev->dev.of_node) { rc = get_device_tree_data(pdev); if (rc) { - pr_err("Error reading MHI Dev DT\n"); + mhi_log(MHI_MSG_ERROR, + "Error reading MHI Dev DT\n"); return rc; } mhi_ipc_log = ipc_log_context_create(MHI_IPC_LOG_PAGES, @@ -4445,6 +4522,12 @@ static int mhi_dev_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Failed to create IPC logging context\n"); } + mhi_ipc_err_log = ipc_log_context_create(MHI_IPC_ERR_LOG_PAGES, + "mhi_err", 0); + if (mhi_ipc_err_log == NULL) { + dev_err(&pdev->dev, + "Failed to create IPC ERR logging context\n"); + } /* * The below list and mutex should be initialized * before calling mhi_uci_init to avoid crash in @@ -4460,13 +4543,15 @@ static int mhi_dev_probe(struct platform_device *pdev) if (mhi_ctx->use_edma) { rc = mhi_edma_init(&pdev->dev); if (rc) { - pr_err("MHI: mhi edma init failed, rc = %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "MHI: mhi edma init failed, rc = %d\n", rc); return rc; } rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); if (rc) { - pr_err("Error set MHI DMA mask: rc = %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Error set MHI DMA mask: rc = %d\n", rc); return rc; } } @@ -4487,7 +4572,7 @@ static int mhi_dev_probe(struct platform_device *pdev) mhi_ctx->pcie_event_wq = alloc_workqueue("mhi_dev_pcie_event_wq", WQ_HIGHPRI, 0); if (!mhi_ctx->pcie_event_wq) { - pr_err("no memory\n"); + mhi_log(MHI_MSG_ERROR, "no memory\n"); rc = -ENOMEM; return rc; } @@ -4497,7 +4582,8 @@ static int mhi_dev_probe(struct platform_device *pdev) /* PCIe link is already up */ rc = mhi_dev_resume_mmio_mhi_init(mhi_ctx); if (rc) { - pr_err("Error during MHI device initialization\n"); + mhi_log(MHI_MSG_ERROR, + "Error during MHI device initialization\n"); return rc; } } else { @@ -4511,7 +4597,8 @@ static int mhi_dev_probe(struct platform_device *pdev) rc = ep_pcie_register_event(mhi_ctx->phandle, &mhi_ctx->event_reg); if (rc) { - pr_err("Failed to register for events from PCIe\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to register for events from PCIe\n"); return rc; } } diff --git a/drivers/platform/msm/mhi_dev/mhi.h b/drivers/platform/msm/mhi_dev/mhi.h index a7a34668a04f..16e0c1f7ed0a 100644 --- a/drivers/platform/msm/mhi_dev/mhi.h +++ b/drivers/platform/msm/mhi_dev/mhi.h @@ -673,7 +673,9 @@ enum mhi_msg_level { extern uint32_t bhi_imgtxdb; extern enum mhi_msg_level mhi_msg_lvl; extern enum mhi_msg_level mhi_ipc_msg_lvl; +extern enum mhi_msg_level mhi_ipc_err_msg_lvl; extern void *mhi_ipc_log; +extern void *mhi_ipc_err_log; #define mhi_log(_msg_lvl, _msg, ...) do { \ if (_msg_lvl >= mhi_msg_lvl) { \ @@ -682,7 +684,11 @@ extern void *mhi_ipc_log; } \ if (mhi_ipc_log && (_msg_lvl >= mhi_ipc_msg_lvl)) { \ ipc_log_string(mhi_ipc_log, \ - "[0x%x %s] " _msg, bhi_imgtxdb, __func__, ##__VA_ARGS__); \ + "[0x%x %s] " _msg, bhi_imgtxdb, __func__, ##__VA_ARGS__); \ + } \ + if (mhi_ipc_err_log && (_msg_lvl >= mhi_ipc_err_msg_lvl)) { \ + ipc_log_string(mhi_ipc_err_log, \ + "[0x%x %s] " _msg, bhi_imgtxdb, __func__, ##__VA_ARGS__); \ } \ } while (0) diff --git a/drivers/platform/msm/mhi_dev/mhi_dev_net.c b/drivers/platform/msm/mhi_dev/mhi_dev_net.c index c4b9d6972e33..ac236edfe928 100644 --- a/drivers/platform/msm/mhi_dev/mhi_dev_net.c +++ b/drivers/platform/msm/mhi_dev/mhi_dev_net.c @@ -43,7 +43,7 @@ enum mhi_dev_net_dbg_lvl { MSG_NET_reserved = 0x80000000 }; -static enum mhi_dev_net_dbg_lvl mhi_net_msg_lvl = MHI_CRITICAL; +static enum mhi_dev_net_dbg_lvl mhi_net_msg_lvl = MHI_ERROR; static enum mhi_dev_net_dbg_lvl mhi_net_ipc_log_lvl = MHI_VERBOSE; static void *mhi_net_ipc_log; @@ -144,7 +144,7 @@ static void mhi_dev_net_process_queue_packets(struct work_struct *work) struct mhi_req *wreq = NULL; if (mhi_dev_channel_isempty(client->in_handle)) { - mhi_dev_net_log(MHI_INFO, "%s stop network xmmit\n", __func__); + mhi_dev_net_log(MHI_INFO, "stop network xmmit\n"); netif_stop_queue(client->dev); return; } @@ -176,8 +176,9 @@ static void mhi_dev_net_process_queue_packets(struct work_struct *work) spin_unlock_irqrestore(&client->wrt_lock, flags); xfer_data = mhi_dev_write_channel(wreq); if (xfer_data <= 0) { - pr_err("%s(): Failed to write skb len %d\n", - __func__, skb->len); + mhi_dev_net_log(MHI_ERROR, + "Failed to write skb len %d\n", + skb->len); kfree_skb(skb); return; } @@ -186,8 +187,7 @@ static void mhi_dev_net_process_queue_packets(struct work_struct *work) /* Check if free buffers are available*/ if (mhi_dev_channel_isempty(client->in_handle)) { mhi_dev_net_log(MHI_INFO, - "%s buffers are full stop xmit\n", - __func__); + "buffers are full stop xmit\n"); netif_stop_queue(client->dev); break; } @@ -281,7 +281,7 @@ static ssize_t mhi_dev_net_client_read(struct mhi_dev_net_client *mhi_handle) spin_unlock_irqrestore(&mhi_handle->rd_lock, flags); skb = alloc_skb(MHI_NET_DEFAULT_MTU, GFP_KERNEL); if (skb == NULL) { - pr_err("%s(): skb alloc failed\n", __func__); + mhi_dev_net_log(MHI_ERROR, "skb alloc failed\n"); spin_lock_irqsave(&mhi_handle->rd_lock, flags); list_add_tail(&req->list, &mhi_handle->rx_buffers); spin_unlock_irqrestore(&mhi_handle->rd_lock, flags); @@ -298,7 +298,8 @@ static ssize_t mhi_dev_net_client_read(struct mhi_dev_net_client *mhi_handle) bytes_avail = mhi_dev_read_channel(req); if (bytes_avail < 0) { - pr_err("Failed to read chan %d bytes_avail = %d\n", + mhi_dev_net_log(MHI_ERROR, + "Failed to read chan %d bytes_avail = %d\n", chan, bytes_avail); spin_lock_irqsave(&mhi_handle->rd_lock, flags); kfree_skb(skb); @@ -473,7 +474,8 @@ static int mhi_dev_net_enable_iface(struct mhi_dev_net_client *mhi_dev_net_ptr) mhi_dev_net_ether_setup : mhi_dev_net_rawip_setup); if (!netdev) { - pr_err("Failed to allocate netdev for mhi_dev_net\n"); + mhi_dev_net_log(MHI_ERROR, + "Failed to allocate netdev for mhi_dev_net\n"); goto net_dev_alloc_fail; } @@ -488,7 +490,8 @@ static int mhi_dev_net_enable_iface(struct mhi_dev_net_client *mhi_dev_net_ptr) *mhi_dev_net_ctxt = mhi_dev_net_ptr; ret = register_netdev(mhi_dev_net_ptr->dev); if (ret) { - pr_err("Failed to register mhi_dev_net device\n"); + mhi_dev_net_log(MHI_ERROR, + "Failed to register mhi_dev_net device\n"); goto net_dev_reg_fail; } mhi_dev_net_log(MHI_INFO, "Successfully registred mhi_dev_net\n"); @@ -546,12 +549,14 @@ static int mhi_dev_net_open_chan_create_netif(struct mhi_dev_net_client *client) ret = mhi_dev_net_alloc_read_reqs(client); if (ret) { - pr_err("failed to allocate rx req buffers\n"); + mhi_dev_net_log(MHI_ERROR, + "failed to allocate rx req buffers\n"); goto rx_req_failed; } ret = mhi_dev_net_alloc_write_reqs(client); if (ret) { - pr_err("failed to allocate write req buffers\n"); + mhi_dev_net_log(MHI_ERROR, + "failed to allocate write req buffers\n"); goto tx_req_failed; } if (atomic_read(&client->tx_enabled)) { diff --git a/drivers/platform/msm/mhi_dev/mhi_mmio.c b/drivers/platform/msm/mhi_dev/mhi_mmio.c index a6aebc969a59..44f64b679cb5 100644 --- a/drivers/platform/msm/mhi_dev/mhi_mmio.c +++ b/drivers/platform/msm/mhi_dev/mhi_mmio.c @@ -101,7 +101,7 @@ static int mhi_dev_mmio_mask_set_chdb_int_a7(struct mhi_dev *dev, chid_idx = chdb_id/32; if (chid_idx >= MHI_MASK_ROWS_CH_EV_DB) { - pr_err("Invalid channel id:%d\n", chid_idx); + mhi_log(MHI_MSG_ERROR, "Invalid channel id:%d\n", chid_idx); return -EINVAL; } @@ -633,7 +633,7 @@ int mhi_dev_restore_mmio(struct mhi_dev *dev) rc = mhi_dev_mmio_write(dev, MHI_CHDB_INT_MASK_A7_n(i), dev->chdb[i].mask); if (rc) { - mhi_log(MHI_MSG_VERBOSE, + mhi_log(MHI_MSG_ERROR, "Error writing enable for A7\n"); return rc; } diff --git a/drivers/platform/msm/mhi_dev/mhi_ring.c b/drivers/platform/msm/mhi_dev/mhi_ring.c index e7b6fb4c389e..a94cc2389efe 100644 --- a/drivers/platform/msm/mhi_dev/mhi_ring.c +++ b/drivers/platform/msm/mhi_dev/mhi_ring.c @@ -143,7 +143,7 @@ int mhi_dev_update_wr_offset(struct mhi_dev_ring *ring) case RING_TYPE_CMD: rc = mhi_dev_mmio_get_cmd_db(ring, &wr_offset); if (rc) { - pr_err("%s: CMD DB read failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "CMD DB read failed\n"); return rc; } mhi_log(MHI_MSG_VERBOSE, @@ -153,14 +153,14 @@ int mhi_dev_update_wr_offset(struct mhi_dev_ring *ring) case RING_TYPE_ER: rc = mhi_dev_mmio_get_erc_db(ring, &wr_offset); if (rc) { - pr_err("%s: EVT DB read failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "EVT DB read failed\n"); return rc; } break; case RING_TYPE_CH: rc = mhi_dev_mmio_get_ch_db(ring, &wr_offset); if (rc) { - pr_err("%s: CH DB read failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "CH DB read failed\n"); return rc; } mhi_log(MHI_MSG_VERBOSE, @@ -237,7 +237,7 @@ int mhi_dev_process_ring(struct mhi_dev_ring *ring) /* notify the clients that there are elements in the ring */ rc = mhi_dev_process_ring_element(ring, ring->rd_offset); if (rc) - pr_err("Error fetching elements\n"); + mhi_log(MHI_MSG_ERROR, "Error fetching elements\n"); return rc; } mhi_log(MHI_MSG_VERBOSE, @@ -490,19 +490,6 @@ int mhi_ring_start(struct mhi_dev_ring *ring, union mhi_dev_ring_ctx *ctx, ring->ring_shadow.device_va = mhi->ctrl_base.device_va + offset; ring->ring_shadow.host_pa = mhi->ctrl_base.host_pa + offset; - if (ring->type == RING_TYPE_ER) - ring->ring_ctx_shadow = - (union mhi_dev_ring_ctx *) (mhi->ev_ctx_shadow.device_va + - (ring->id - mhi->ev_ring_start) * - sizeof(union mhi_dev_ring_ctx)); - else if (ring->type == RING_TYPE_CMD) - ring->ring_ctx_shadow = - (union mhi_dev_ring_ctx *) mhi->cmd_ctx_shadow.device_va; - else if (ring->type == RING_TYPE_CH) - ring->ring_ctx_shadow = - (union mhi_dev_ring_ctx *) (mhi->ch_ctx_shadow.device_va + - (ring->id - mhi->ch_ring_start)*sizeof(union mhi_dev_ring_ctx)); - ring->ring_ctx_shadow = ring->ring_ctx; if (ring->type != RING_TYPE_ER || ring->type != RING_TYPE_CH) { @@ -574,7 +561,7 @@ void mhi_ring_set_state(struct mhi_dev_ring *ring, return; if (state > RING_STATE_PENDING) { - pr_err("%s: Invalid ring state\n", __func__); + mhi_log(MHI_MSG_ERROR, "Invalid ring state\n"); return; } diff --git a/drivers/platform/msm/mhi_dev/mhi_uci.c b/drivers/platform/msm/mhi_dev/mhi_uci.c index 0039fa48c561..2b458e130201 100644 --- a/drivers/platform/msm/mhi_dev/mhi_uci.c +++ b/drivers/platform/msm/mhi_dev/mhi_uci.c @@ -55,7 +55,7 @@ enum uci_dbg_level { UCI_DBG_reserved = 0x80000000 }; -static enum uci_dbg_level mhi_uci_msg_lvl = UCI_DBG_CRITICAL; +static enum uci_dbg_level mhi_uci_msg_lvl = UCI_DBG_ERROR; static enum uci_dbg_level mhi_uci_ipc_log_lvl = UCI_DBG_INFO; static void *mhi_uci_ipc_log; @@ -944,7 +944,7 @@ static int mhi_uci_read_sync(struct uci_client *uci_handle, int *bytes_avail) struct mhi_req ureq; struct mhi_dev_client *client_handle; - uci_log(UCI_DBG_ERROR, + uci_log(UCI_DBG_INFO, "Sync read for ch %d\n", uci_handle->in_chan); client_handle = uci_handle->in_handle; @@ -985,8 +985,7 @@ static int open_client_mhi_channels(struct uci_client *uci_client) int rc = 0; if (!mhi_uci_are_channels_connected(uci_client)) { - uci_log(UCI_DBG_ERROR, "%s:Channels are not connected\n", - __func__); + uci_log(UCI_DBG_ERROR, "Channels are not connected\n"); return -ENODEV; } @@ -1247,7 +1246,7 @@ static int mhi_state_uevent(struct device *dev, struct kobj_uevent_env *env) rc = mhi_ctrl_state_info(MHI_DEV_UEVENT_CTRL, &info); if (rc) { - pr_err("Failed to obtain MHI_STATE\n"); + uci_log(UCI_DBG_ERROR, "Failed to obtain MHI_STATE\n"); return -EINVAL; } @@ -1257,12 +1256,13 @@ static int mhi_state_uevent(struct device *dev, struct kobj_uevent_env *env) for (i = 0; i < ARRAY_SIZE(mhi_chan_attr_table); i++) { chan_attrib = &mhi_chan_attr_table[i]; if (chan_attrib->state_bcast) { - uci_log(UCI_DBG_ERROR, "Calling notify for ch %d\n", + uci_log(UCI_DBG_INFO, "Calling notify for ch %d\n", chan_attrib->chan_id); rc = mhi_ctrl_state_info(chan_attrib->chan_id, &info); if (rc) { - pr_err("Failed to obtain channel %d state\n", - chan_attrib->chan_id); + uci_log(UCI_DBG_ERROR, + "Failed to obtain channel %d state\n", + chan_attrib->chan_id); return -EINVAL; } nbytes = 0; @@ -1307,7 +1307,7 @@ static ssize_t mhi_uci_ctrl_client_read(struct file *file, "MHI_STATE=DISCONNECTED"); break; default: - pr_err("invalid info:%d\n", info); + uci_log(UCI_DBG_ERROR, "invalid info:%d\n", info); return -EINVAL; } @@ -1329,8 +1329,7 @@ static int __mhi_uci_client_read(struct uci_client *uci_handle, do { if (!mhi_uci_are_channels_connected(uci_handle)) { - uci_log(UCI_DBG_ERROR, - "%s:Channels are not connected\n", __func__); + uci_log(UCI_DBG_ERROR, "Channels are not connected\n"); return -ENODEV; } @@ -1481,8 +1480,7 @@ static ssize_t mhi_uci_client_write(struct file *file, } if (!mhi_uci_are_channels_connected(uci_handle)) { - uci_log(UCI_DBG_ERROR, "%s:Channels are not connected\n", - __func__); + uci_log(UCI_DBG_ERROR, "Channels are not connected\n"); return -ENODEV; } @@ -1541,8 +1539,7 @@ static ssize_t mhi_uci_client_write_iter(struct kiocb *iocb, } if (!mhi_uci_are_channels_connected(uci_handle)) { - uci_log(UCI_DBG_ERROR, "%s:Channels are not connected\n", - __func__); + uci_log(UCI_DBG_ERROR, "Channels are not connected\n"); return -ENODEV; } @@ -1651,7 +1648,7 @@ void uci_ctrl_update(struct mhi_dev_client_cb_reason *reason) if (reason->reason == MHI_DEV_CTRL_UPDATE) { uci_ctrl_handle = &uci_ctxt.ctrl_handle; if (!uci_ctrl_handle) { - pr_err("Invalid uci ctrl handle\n"); + uci_log(UCI_DBG_ERROR, "Invalid uci ctrl handle\n"); return; } @@ -2254,7 +2251,7 @@ int mhi_uci_init(void) /* Control node */ uci_ctxt.cdev_ctrl = cdev_alloc(); if (uci_ctxt.cdev_ctrl == NULL) { - pr_err("%s: ctrl cdev alloc failed\n", __func__); + uci_log(UCI_DBG_ERROR, "ctrl cdev alloc failed\n"); return 0; } From e853650437ff6b002250cdd76ee58dc02c6f7787 Mon Sep 17 00:00:00 2001 From: Rohit Agarwal Date: Wed, 23 Feb 2022 15:42:32 +0530 Subject: [PATCH 42/48] defconfig: Enable the System V IPC config on sdxlemur Enable SYSVIPC for library functions and syscalls. Change-Id: I51334bb8fb06d34f7783c655bf03401bea86c26b Signed-off-by: Rohit Agarwal --- arch/arm/configs/vendor/sdxlemur.config | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/vendor/sdxlemur.config b/arch/arm/configs/vendor/sdxlemur.config index 8cdf99ab5a29..bb2d436b3e62 100644 --- a/arch/arm/configs/vendor/sdxlemur.config +++ b/arch/arm/configs/vendor/sdxlemur.config @@ -380,3 +380,4 @@ CONFIG_GKI_HIDDEN_DRM_CONFIGS=y CONFIG_SDX_EXT_IPC=y # CONFIG_SCHED_DEBUG is not set CONFIG_MACSEC=y +CONFIG_SYSVIPC=y From fa83be69c926610add026a53b50714c707a8c965 Mon Sep 17 00:00:00 2001 From: Pradeep P V K Date: Fri, 25 Mar 2022 15:15:58 +0530 Subject: [PATCH 43/48] ubi: Use PAGE_SIZE as size field for ubi sysfs show attributes To avoid truncation and to show correct ubi sysfs show attribute values, use PAGE_SIZE as a buffer size value. Change-Id: I4cf84967437b7baae0f10f00fd3d8726f780af16 Signed-off-by: Pradeep P V K --- drivers/mtd/ubi/build.c | 34 +++++++++++++++++----------------- drivers/mtd/ubi/vmt.c | 25 +++++++++++-------------- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 971c3b7a51c3..2eff13c24253 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -95,7 +95,7 @@ static DEFINE_SPINLOCK(ubi_devices_lock); static ssize_t version_show(struct class *class, struct class_attribute *attr, char *buf) { - return scnprintf(buf, sizeof(int), "%d\n", UBI_VERSION); + return scnprintf(buf, PAGE_SIZE, "%d\n", UBI_VERSION); } static CLASS_ATTR_RO(version); @@ -376,49 +376,49 @@ static ssize_t dev_attribute_show(struct device *dev, return -ENODEV; if (attr == &dev_eraseblock_size) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", ubi->leb_size); else if (attr == &dev_avail_eraseblocks) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", ubi->avail_pebs); else if (attr == &dev_total_eraseblocks) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", ubi->good_peb_count); else if (attr == &dev_volumes_count) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", ubi->vol_count - UBI_INT_VOL_COUNT); else if (attr == &dev_max_ec) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", ubi->max_ec); else if (attr == &dev_reserved_for_bad) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", ubi->beb_rsvd_pebs); else if (attr == &dev_bad_peb_count) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", ubi->bad_peb_count); else if (attr == &dev_max_vol_count) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", ubi->vtbl_slots); else if (attr == &dev_min_io_size) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", ubi->min_io_size); else if (attr == &dev_bgt_enabled) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", ubi->thread_enabled); else if (attr == &dev_mtd_num) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", ubi->mtd->index); else if (attr == &dev_ro_mode) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", ubi->ro_mode); else if (attr == &dev_mtd_trigger_scrub) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&ubi->scrub_work_count)); else if (attr == &dev_mtd_max_scrub_sqnum) - ret = scnprintf(buf, sizeof(unsigned long long), "%llu\n", + ret = scnprintf(buf, PAGE_SIZE, "%llu\n", get_max_sqnum(ubi)); else if (attr == &dev_mtd_min_scrub_sqnum) - ret = scnprintf(buf, sizeof(unsigned long long), "%llu\n", + ret = scnprintf(buf, PAGE_SIZE, "%llu\n", ubi_wl_scrub_get_min_sqnum(ubi)); else ret = -EINVAL; @@ -516,7 +516,7 @@ static int uif_init(struct ubi_device *ubi) int i, err; dev_t dev; - scnprintf(ubi->ubi_name, sizeof(UBI_NAME_STR) + 5, + scnprintf(ubi->ubi_name, sizeof(ubi->ubi_name), UBI_NAME_STR "%d", ubi->ubi_num); /* diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index e1fa76b88469..c1d562f6b7e5 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c @@ -54,7 +54,7 @@ static struct device_attribute attr_vol_upd_marker = static ssize_t vol_attribute_show(struct device *dev, struct device_attribute *attr, char *buf) { - int ret, size; + int ret; struct ubi_volume *vol = container_of(dev, struct ubi_volume, dev); struct ubi_device *ubi; @@ -73,35 +73,32 @@ static ssize_t vol_attribute_show(struct device *dev, spin_unlock(&ubi->volumes_lock); if (attr == &attr_vol_reserved_ebs) - ret = scnprintf(buf, sizeof(int), "%d\n", vol->reserved_pebs); + ret = scnprintf(buf, PAGE_SIZE, "%d\n", vol->reserved_pebs); else if (attr == &attr_vol_type) { const char *tp; - if (vol->vol_type == UBI_DYNAMIC_VOLUME) { + if (vol->vol_type == UBI_DYNAMIC_VOLUME) tp = "dynamic"; - size = 8; - } else { + else tp = "static"; - size = 7; - } - ret = scnprintf(buf, size, "%s\n", tp); + ret = scnprintf(buf, PAGE_SIZE, "%s\n", tp); } else if (attr == &attr_vol_name) - ret = scnprintf(buf, UBI_MAX_VOLUME_NAME + 1, "%s\n", + ret = scnprintf(buf, PAGE_SIZE, "%s\n", vol->name); else if (attr == &attr_vol_corrupted) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", vol->corrupted); else if (attr == &attr_vol_alignment) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", vol->alignment); else if (attr == &attr_vol_usable_eb_size) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", vol->usable_leb_size); else if (attr == &attr_vol_data_bytes) - ret = scnprintf(buf, sizeof(unsigned long long), "%lld\n", + ret = scnprintf(buf, PAGE_SIZE, "%lld\n", vol->used_bytes); else if (attr == &attr_vol_upd_marker) - ret = scnprintf(buf, sizeof(int), "%d\n", + ret = scnprintf(buf, PAGE_SIZE, "%d\n", vol->upd_marker); else /* This must be a bug */ From 0f01b87836b73f937a28370add6df2d200e64eca Mon Sep 17 00:00:00 2001 From: Mohammed Siddiq Date: Tue, 22 Mar 2022 16:25:00 +0530 Subject: [PATCH 44/48] cnss2: Add code to show firmware capability as part of debug stats Add code to show firmware capability as part of debug stats. Change-Id: I1048b8ec3a2b43f83d961c0154fc9da0b4be2792 Signed-off-by: Mohammed Siddiq --- drivers/net/wireless/cnss2/debug.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/net/wireless/cnss2/debug.c b/drivers/net/wireless/cnss2/debug.c index 84b5deeeff3a..c58133204ec7 100644 --- a/drivers/net/wireless/cnss2/debug.c +++ b/drivers/net/wireless/cnss2/debug.c @@ -136,12 +136,36 @@ static int cnss_stats_show_state(struct seq_file *s, return 0; } +static int cnss_stats_show_capability(struct seq_file *s, + struct cnss_plat_data *plat_priv) +{ + if (test_bit(CNSS_FW_READY, &plat_priv->driver_state)) { + seq_puts(s, "\n<---------------- FW Capability ----------------->\n"); + seq_printf(s, "Chip ID: 0x%x\n", plat_priv->chip_info.chip_id); + seq_printf(s, "Chip family: 0x%x\n", + plat_priv->chip_info.chip_family); + seq_printf(s, "Board ID: 0x%x\n", + plat_priv->board_info.board_id); + seq_printf(s, "SOC Info: 0x%x\n", plat_priv->soc_info.soc_id); + seq_printf(s, "Firmware Version: 0x%x\n", + plat_priv->fw_version_info.fw_version); + seq_printf(s, "Firmware Build Timestamp: %s\n", + plat_priv->fw_version_info.fw_build_timestamp); + seq_printf(s, "Firmware Build ID: %s\n", + plat_priv->fw_build_id); + } + + return 0; +} + static int cnss_stats_show(struct seq_file *s, void *data) { struct cnss_plat_data *plat_priv = s->private; cnss_stats_show_state(s, plat_priv); + cnss_stats_show_capability(s, plat_priv); + return 0; } From 8c4e938dcff62632a6de0aaa99ba7ed457fc5f61 Mon Sep 17 00:00:00 2001 From: Rohith Kollalsi Date: Mon, 28 Mar 2022 23:12:52 +0530 Subject: [PATCH 45/48] usb: f_cdev: Fix failure in function resume in f_cdev Currently there is a fault in implementation of function suspend and resume in f_cdev. In case when function suspend is issued by the host and then cleared, still cser_resume is not being performed. This is due to incorrect handling of if else condition in usb_cser_func_suspend. Fix this by adding proper handling. Change-Id: I4f0e4c6c02d4b30f2fe0b67bc39a4fac9dbf96f1 Signed-off-by: Rohith Kollalsi --- drivers/usb/gadget/function/f_cdev.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/function/f_cdev.c b/drivers/usb/gadget/function/f_cdev.c index 9de5f19f3bbf..33d3a37dafd9 100644 --- a/drivers/usb/gadget/function/f_cdev.c +++ b/drivers/usb/gadget/function/f_cdev.c @@ -610,11 +610,11 @@ static int usb_cser_func_suspend(struct usb_function *f, u8 options) if (!port->func_is_suspended) { usb_cser_suspend(f); port->func_is_suspended = true; - } else { - if (port->func_is_suspended) { - port->func_is_suspended = false; - usb_cser_resume(f); - } + } + } else { + if (port->func_is_suspended) { + port->func_is_suspended = false; + usb_cser_resume(f); } } return 0; From da85175a9fbe3573b4d0be1f0b0e10cae62781c6 Mon Sep 17 00:00:00 2001 From: Jyothi Kumar Seerapu Date: Tue, 22 Mar 2022 11:50:21 +0530 Subject: [PATCH 46/48] msm: mhi_dev: Change MHI logs for Channel and Ring Ids Currently the MHI logs are not unique for channel and ring ids. Post this change, all channel ids can be found with ch_id:xx and all ring ids can be found with ring_id:yy in MHI logs, thus making the debugging process easier. Change-Id: I6352911814795792f796b2062da6465da7af89ff Signed-off-by: Jyothi Kumar Seerapu --- drivers/platform/msm/mhi_dev/mhi.c | 183 +++++++++++---------- drivers/platform/msm/mhi_dev/mhi_dev_net.c | 27 +-- drivers/platform/msm/mhi_dev/mhi_mmio.c | 2 +- drivers/platform/msm/mhi_dev/mhi_ring.c | 35 ++-- drivers/platform/msm/mhi_dev/mhi_uci.c | 103 ++++++------ 5 files changed, 185 insertions(+), 165 deletions(-) diff --git a/drivers/platform/msm/mhi_dev/mhi.c b/drivers/platform/msm/mhi_dev/mhi.c index 89cb1a703035..1b6259bdcaba 100644 --- a/drivers/platform/msm/mhi_dev/mhi.c +++ b/drivers/platform/msm/mhi_dev/mhi.c @@ -300,14 +300,16 @@ static int mhi_dev_schedule_msi_ipa(struct mhi_dev *mhi, struct event_req *ereq) ereq->msi_cb = mhi_dev_event_msi_cb; ch->msi_cnt++; mhi_log(MHI_MSG_VERBOSE, - "Sending MSI %d to 0x%llx as data = 0x%x for ch %d msi_count %d, ereq flush_num %d\n", + "Sending MSI %d to 0x%llx as data = 0x%x for ch_id:%d\t" + "msi_count %d, ereq flush_num %d\n", ctx->ev.msivec, msi_addr.host_pa, *ring->msi_buf, ch->ch_id, ch->msi_cnt, ereq->flush_num); } else { ereq->msi_cb = mhi_dev_cmd_event_msi_cb; mhi_log(MHI_MSG_VERBOSE, - "Sending MSI %d to 0x%llx as data = 0x%x for cmd ack, ereq flush_num %d\n", + "Sending MSI %d to 0x%llx as data = 0x%x for cmd ack\t" + "ereq flush_num %d\n", ctx->ev.msivec, msi_addr.host_pa, *ring->msi_buf, ereq->flush_num); } @@ -471,12 +473,12 @@ static int mhi_dev_send_multiple_tr_events(struct mhi_dev *mhi, int evnt_ring, if (evnt_ring_idx > mhi->cfg.event_rings) { mhi_log(MHI_MSG_ERROR, - "Invalid event ring idx: %lld\n", evnt_ring_idx); + "Invalid event ring_id:%lld\n", evnt_ring_idx); return -EINVAL; } if (!ring) { - mhi_log(MHI_MSG_ERROR, "Ring %d not present\n", + mhi_log(MHI_MSG_ERROR, "ring_id:%d not present\n", evnt_ring_idx); return -EINVAL; } @@ -487,7 +489,8 @@ static int mhi_dev_send_multiple_tr_events(struct mhi_dev *mhi, int evnt_ring, rc = mhi_ring_start(ring, ctx, mhi); if (rc) { mhi_log(MHI_MSG_ERROR, - "error starting event ring %d\n", evnt_ring); + "error starting event ring_id:%d\n", + evnt_ring_idx); return rc; } } @@ -513,12 +516,12 @@ static int mhi_dev_send_multiple_tr_events(struct mhi_dev *mhi, int evnt_ring, if (ch->state == MHI_DEV_CH_STOPPED || ch->state == MHI_DEV_CH_PENDING_STOP) { mhi_log(MHI_MSG_ERROR, - "Ch:%d is in %d state, abort sending completion evnt\n" + "ch_id:%d is in %d state, abort sending cmpl evnt\n" , ch->ch_id, ch->state); rc = -ENXIO; goto exit; } - mhi_log(MHI_MSG_VERBOSE, "Flushing %d cmpl events of ch %d\n", + mhi_log(MHI_MSG_VERBOSE, "Flushing %d cmpl events of ch_id:%d\n", ereq->num_events, ch->ch_id); } else { mhi_log(MHI_MSG_VERBOSE, @@ -651,7 +654,7 @@ static int mhi_dev_flush_transfer_completion_events(struct mhi_dev *mhi, if (ch->state == MHI_DEV_CH_CLOSED || ch->state == MHI_DEV_CH_STOPPED) { mhi_log(MHI_MSG_DBG, - "Ch %d closed with %d writes pending\n", + "ch_id:%d closed with %d writes pending\n", ch->ch_id, ch->pend_wr_count + 1); rc = -ENODEV; break; @@ -667,7 +670,7 @@ static int mhi_dev_flush_transfer_completion_events(struct mhi_dev *mhi, if (ch->flush_req_cnt++ >= U32_MAX) ch->flush_req_cnt = 0; flush_ereq->flush_num = ch->flush_req_cnt; - mhi_log(MHI_MSG_DBG, "Flush num %d called for ch %d\n", + mhi_log(MHI_MSG_DBG, "Flush num %d called for ch_id:%d\n", ch->flush_req_cnt, ch->ch_id); /* Check the limits of the buffer to be flushed */ @@ -852,12 +855,14 @@ int mhi_transfer_host_to_device_ipa(void *dev, uint64_t host_pa, uint32_t len, mhi_log(MHI_MSG_VERBOSE, "device 0x%llx <-- host 0x%llx, size %d\n", (uint64_t) mhi->read_dma_handle, host_addr_pa, (int) len); + ch = mreq->client->channel; if (mreq->mode == DMA_SYNC) { rc = ipa_dma_sync_memcpy((u64) mhi->read_dma_handle, host_addr_pa, (int) len); if (rc) { mhi_log(MHI_MSG_ERROR, - "error while reading chan using sync:%d\n", rc); + "error while reading ch_id:%d using sync, rc\n", + ch->ch_id, rc); return rc; } memcpy(dev, mhi->read_handle, len); @@ -870,7 +875,8 @@ int mhi_transfer_host_to_device_ipa(void *dev, uint64_t host_pa, uint32_t len, if (ring->rd_offset == ring->wr_offset) { mhi_log(MHI_MSG_VERBOSE, - "Setting snd_cmpl to 1 for ch %d\n", ch->ch_id); + "Setting snd_cmpl to 1 for ch_id:%d\n", + ch->ch_id); mreq->snd_cmpl = 1; } @@ -878,7 +884,7 @@ int mhi_transfer_host_to_device_ipa(void *dev, uint64_t host_pa, uint32_t len, rc = mhi_dev_queue_transfer_completion(mreq, NULL); if (rc) { mhi_log(MHI_MSG_ERROR, - "Failed to queue completion for ch %d, rc %d\n", + "Failed to queue completion for ch_id:%d, rc %d\n", ch->ch_id, rc); return rc; } @@ -888,7 +894,8 @@ int mhi_transfer_host_to_device_ipa(void *dev, uint64_t host_pa, uint32_t len, mreq); if (rc) { mhi_log(MHI_MSG_ERROR, - "DMA read error %d for ch %d\n", rc, ch->ch_id); + "DMA read error %d for ch_id:%d\n", + rc, ch->ch_id); /* Roll back the completion event that we wrote above */ mhi_dev_rollback_compl_evt(ch); /* Unmap the buffer */ @@ -1187,7 +1194,8 @@ int mhi_transfer_host_to_device_edma(void *dev, uint64_t host_pa, uint32_t len, if (ring->rd_offset == ring->wr_offset) { mhi_log(MHI_MSG_VERBOSE, - "Setting snd_cmpl to 1 for ch %d\n", ch->ch_id); + "Setting snd_cmpl to 1 for ch_id:%d\n", + ch->ch_id); mreq->snd_cmpl = 1; } @@ -1489,7 +1497,7 @@ static void mhi_hwc_cb(void *priv, enum ipa_mhi_event_type event, switch (event) { case IPA_MHI_EVENT_READY: mhi_log(MHI_MSG_INFO, - "HW Channel uC is ready event=0x%X\n", event); + "HW ch uC is ready event=0x%X\n", event); rc = mhi_hwc_start(mhi_ctx); if (rc) { mhi_log(MHI_MSG_ERROR, @@ -1516,7 +1524,7 @@ static void mhi_hwc_cb(void *priv, enum ipa_mhi_event_type event, break; default: mhi_log(MHI_MSG_ERROR, - "HW Channel uC unknown event 0x%X\n", event); + "HW ch uC unknown event 0x%X\n", event); break; } } @@ -1534,7 +1542,7 @@ static int mhi_hwc_chcmd(struct mhi_dev *mhi, uint chid, case MHI_DEV_RING_EL_STOP: if ((chid-HW_CHANNEL_BASE) > NUM_HW_CHANNELS) { mhi_log(MHI_MSG_ERROR, - "Invalid Channel ID = 0x%X\n", chid); + "Invalid HW ch_id:%d\n", chid); return -EINVAL; } @@ -1542,7 +1550,7 @@ static int mhi_hwc_chcmd(struct mhi_dev *mhi, uint chid, mhi->ipa_clnt_hndl[chid-HW_CHANNEL_BASE]); if (rc) mhi_log(MHI_MSG_ERROR, - "Stopping HW Channel%d failed 0x%X\n", + "Stopping HW ch_id:%d failed 0x%X\n", chid, rc); break; case MHI_DEV_RING_EL_START: @@ -1551,13 +1559,13 @@ static int mhi_hwc_chcmd(struct mhi_dev *mhi, uint chid, if (chid > HW_CHANNEL_END) { mhi_log(MHI_MSG_ERROR, - "Channel DB for %d not enabled\n", chid); + "ch DB for ch_id:%d not enabled\n", chid); return -EINVAL; } if ((chid-HW_CHANNEL_BASE) > NUM_HW_CHANNELS) { mhi_log(MHI_MSG_ERROR, - "Invalid Channel = 0x%X\n", chid); + "Invalid HW ch_id:%d\n", chid); return -EINVAL; } @@ -1565,7 +1573,7 @@ static int mhi_hwc_chcmd(struct mhi_dev *mhi, uint chid, &mhi->ipa_clnt_hndl[chid-HW_CHANNEL_BASE]); if (rc) mhi_log(MHI_MSG_ERROR, - "HW Channel%d start failed : %d\n", + "HW ch_id:%d start failed : %d\n", chid, rc); break; case MHI_DEV_RING_EL_INVALID: @@ -1641,7 +1649,7 @@ int mhi_dev_send_event(struct mhi_dev *mhi, int evnt_ring, if (evnt_ring_idx > mhi->cfg.event_rings) { mhi_log(MHI_MSG_ERROR, - "Invalid event ring idx: %lld\n", evnt_ring_idx); + "Invalid event ring_id: %lld\n", evnt_ring_idx); return -EINVAL; } @@ -1650,7 +1658,8 @@ int mhi_dev_send_event(struct mhi_dev *mhi, int evnt_ring, rc = mhi_ring_start(ring, ctx, mhi); if (rc) { mhi_log(MHI_MSG_ERROR, - "error starting event ring %d\n", evnt_ring); + "error starting event ring_id:%d\n", + evnt_ring_idx); return rc; } } @@ -1719,12 +1728,12 @@ static int mhi_dev_send_completion_event_async(struct mhi_dev_channel *ch, rc = mhi_dev_queue_transfer_completion(mreq, NULL); if (rc) { mhi_log(MHI_MSG_ERROR, - "Failed to queue completion for ch %d, rc %d\n", + "Failed to queue completion for ch_id:%d, rc %d\n", ch->ch_id, rc); return rc; } - mhi_log(MHI_MSG_VERBOSE, "Calling flush for ch %d\n", ch->ch_id); + mhi_log(MHI_MSG_VERBOSE, "Calling flush for ch_id:%d\n", ch->ch_id); rc = mhi_dev_flush_transfer_completion_events(mhi, ch); if (rc) { mhi_log(MHI_MSG_ERROR, @@ -1878,7 +1887,7 @@ static void mhi_dev_process_reset_cmd(struct mhi_dev *mhi, int ch_id) rc = mhi_dev_mmio_disable_chdb_a7(mhi, ch_id); if (rc) { mhi_log(MHI_MSG_VERBOSE, - "Failed to disable chdb for ch %d\n", ch_id); + "Failed to disable chdb for ch_id:%d\n", ch_id); rc = mhi_dev_send_cmd_comp_event(mhi, MHI_CMD_COMPL_CODE_UNDEFINED); if (rc) @@ -1888,7 +1897,7 @@ static void mhi_dev_process_reset_cmd(struct mhi_dev *mhi, int ch_id) } ch = &mhi->ch[ch_id]; - mhi_log(MHI_MSG_VERBOSE, "Processing reset cmd for ch%d\n", ch_id); + mhi_log(MHI_MSG_VERBOSE, "Processing reset cmd for ch_id:%d\n", ch_id); /* * Ensure that the completions that are present in the flush list are * removed from the list and added to event req list before channel @@ -1946,18 +1955,18 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, union mhi_dev_ring_ctx *evt_ctx; ch_id = el->generic.chid; - mhi_log(MHI_MSG_VERBOSE, "for channel:%d and cmd:%d\n", + mhi_log(MHI_MSG_VERBOSE, "for ch_id:%d and cmd %d\n", ch_id, el->generic.type); switch (el->generic.type) { case MHI_DEV_RING_EL_START: - mhi_log(MHI_MSG_VERBOSE, "received start cmd for channel %d\n", + mhi_log(MHI_MSG_VERBOSE, "received start cmd for ch_id:%d\n", ch_id); if (ch_id >= (HW_CHANNEL_BASE)) { rc = mhi_hwc_chcmd(mhi, ch_id, el->generic.type); if (rc) { mhi_log(MHI_MSG_ERROR, - "Error with HW channel cmd %d\n", rc); + "Error with HW ch cmd %d\n", rc); rc = mhi_dev_send_cmd_comp_event(mhi, MHI_CMD_COMPL_CODE_UNDEFINED); if (rc) @@ -1970,7 +1979,7 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, rc = mhi_dev_mmio_enable_chdb_a7(mhi, ch_id); if (rc) { mhi_log(MHI_MSG_VERBOSE, - "Failed to enable chdb for ch %d\n", + "Failed to enable chdb for ch_id:%d\n", ch_id); goto send_undef_completion_event; } @@ -1985,7 +1994,7 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, mhi); if (rc) { mhi_log(MHI_MSG_ERROR, - "start ring failed for ch %d\n", ch_id); + "start ring failed for ch_id:%d\n", ch_id); goto send_undef_completion_event; } @@ -2010,7 +2019,7 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, rc = mhi_ring_start(evt_ring, evt_ctx, mhi); if (rc) { mhi_log(MHI_MSG_ERROR, - "error starting event ring %d\n", + "error starting event ring_id:%d\n", mhi->ch_ctx_cache[ch_id].err_indx); goto send_undef_completion_event; } @@ -2034,7 +2043,8 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, MHI_CMD_COMPL_CODE_SUCCESS); if (rc) mhi_log(MHI_MSG_ERROR, - "Error sending command completion event\n"); + "Error sending compl event for ch_id:%d\n", + ch_id); mhi_update_state_info_ch(ch_id, MHI_STATE_CONNECTED); /* Trigger callback to clients */ @@ -2060,7 +2070,8 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, rc = mhi_hwc_chcmd(mhi, ch_id, el->generic.type); if (rc) mhi_log(MHI_MSG_ERROR, - "send channel stop cmd event failed\n"); + "send ch stop cmd event failed for ch_id:%d\n", + ch_id); /* send the completion event to the host */ event.evt_cmd_comp.ptr = mhi->cmd_ctx_cache->rbase + @@ -2092,7 +2103,8 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, ring = &mhi->ring[ch_id + mhi->ch_ring_start]; if (ring->state == RING_STATE_UINT) { mhi_log(MHI_MSG_ERROR, - "Channel not opened for %d\n", ch_id); + "Channel not opened for ch_id:%d\n", + ch_id); return -EINVAL; } @@ -2125,7 +2137,8 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, rc = mhi_hwc_chcmd(mhi, ch_id, el->generic.type); if (rc) mhi_log(MHI_MSG_ERROR, - "send channel stop cmd event failed\n"); + "send ch stop cmd event failed ch_id:%d\n", + ch_id); /* send the completion event to the host */ event.evt_cmd_comp.ptr = mhi->cmd_ctx_cache->rbase + @@ -2143,7 +2156,8 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, rc = mhi_dev_flush_cmd_completion_events(mhi, &event); if (rc) { mhi_log(MHI_MSG_ERROR, - "stop event send failed\n"); + "stop event send failed for ch_id:%d\n", + ch_id); return rc; } } else { @@ -2155,7 +2169,8 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, ring = &mhi->ring[ch_id + mhi->ch_ring_start]; if (ring->state == RING_STATE_UINT) { mhi_log(MHI_MSG_ERROR, - "Channel not opened for %d\n", ch_id); + "Channel not opened for ch_id:%d\n", + ch_id); return -EINVAL; } ch = &mhi->ch[ch_id]; @@ -2163,7 +2178,7 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, mutex_lock(&ch->ring->event_lock); if (ch->db_pending) { mhi_log(MHI_MSG_ERROR, - "skipping reset cmd ack for channel %d\n", + "skipping reset cmd ack for ch_id:%d\n", ch_id); ch->reset_pending = true; mutex_unlock(&ch->ring->event_lock); @@ -2182,7 +2197,8 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi, break; default: mhi_log(MHI_MSG_ERROR, - "Invalid command:%d\n", el->generic.type); + "Invalid command:%d, ch_id:%d\n", + el->generic.type, ch_id); break; } return rc; @@ -2197,7 +2213,7 @@ static int mhi_dev_process_tre_ring(struct mhi_dev *mhi, if (ring->id < mhi->ch_ring_start) { mhi_log(MHI_MSG_VERBOSE, - "invalid channel ring id (%d), should be < %lu\n", + "invalid channel ring_id:%d, should be < %lu\n", ring->id, mhi->ch_ring_start); return -EINVAL; } @@ -2236,11 +2252,11 @@ static void mhi_dev_process_ring_pending(struct work_struct *work) list_for_each_safe(cp, q, &mhi->process_ring_list) { ring = list_entry(cp, struct mhi_dev_ring, list); list_del(cp); - mhi_log(MHI_MSG_VERBOSE, "processing ring %d\n", ring->id); + mhi_log(MHI_MSG_VERBOSE, "processing ring_id:%d\n", ring->id); if (ring->id < mhi->ch_ring_start) { mhi_log(MHI_MSG_ERROR, - "ring (%d) is not a channel ring\n", ring->id); + "ring_id:%d is not a channel ring\n", ring->id); goto exit; } @@ -2249,7 +2265,7 @@ static void mhi_dev_process_ring_pending(struct work_struct *work) rc = mhi_dev_process_ring(ring); if (rc) { mhi_log(MHI_MSG_ERROR, - "error processing ring %d\n", ring->id); + "error processing ring_id:%d\n", ring->id); goto exit; } mutex_lock(&ch->ch_lock); @@ -2264,7 +2280,7 @@ static void mhi_dev_process_ring_pending(struct work_struct *work) */ ch_id = ch->ch_id; mhi_log(MHI_MSG_VERBOSE, - "processing pending ch:%d reset\n", ch_id); + "processing pending ch_id:%d reset\n", ch_id); rc = mhi_dev_process_ring( &mhi->ring[mhi->cmd_ring_idx]); if (rc) { @@ -2325,7 +2341,8 @@ static bool mhi_dev_queue_channel_db(struct mhi_dev *mhi, if (chintr_value & 1) { ring = &mhi->ring[ch_num + mhi->ch_ring_start]; if (ring->state == RING_STATE_UINT) { - pr_debug("Channel not opened for %d\n", ch_num); + pr_debug("Channel not opened for ch_id:%d\n", + ch_num); continue; } mhi_ring_set_state(ring, RING_STATE_PENDING); @@ -2449,7 +2466,7 @@ static int mhi_dev_abort(struct mhi_dev *mhi) rc = mhi_dev_mmio_mask_chdb_interrupts(mhi_ctx); if (rc) { mhi_log(MHI_MSG_ERROR, - "Failed to enable channel db\n"); + "Failed to enable ch db\n"); return rc; } @@ -2518,11 +2535,11 @@ static void mhi_dev_transfer_completion_cb(void *mreq) ch->state == MHI_DEV_CH_STOPPED) { if (inbound) mhi_log(MHI_MSG_DBG, - "Ch %d closed with %d writes pending\n", + "ch_id:%d closed with %d writes pending\n", ch->ch_id, ch->pend_wr_count + 1); else mhi_log(MHI_MSG_DBG, - "Ch %d closed with read pending\n", ch->ch_id); + "ch_id:%d closed with read pending\n", ch->ch_id); return; } @@ -2533,7 +2550,7 @@ static void mhi_dev_transfer_completion_cb(void *mreq) /* Flush read completions to host */ if (snd_cmpl && mhi_ctx->ch_ctx_cache[ch->ch_id].ch_type == MHI_DEV_CH_TYPE_OUTBOUND_CHANNEL) { - mhi_log(MHI_MSG_DBG, "Calling flush for ch %d\n", ch->ch_id); + mhi_log(MHI_MSG_DBG, "Calling flush for ch_id:%d\n", ch->ch_id); rc = mhi_dev_flush_transfer_completion_events(mhi_ctx, ch); if (rc) { mhi_log(MHI_MSG_ERROR, @@ -2546,7 +2563,7 @@ static void mhi_dev_transfer_completion_cb(void *mreq) rc = mhi_dev_process_stop_cmd(ch->ring, ch->ch_id, mhi_ctx); if (rc) mhi_log(MHI_MSG_ERROR, - "Error while stopping channel (%d)\n", ch->ch_id); + "Error while stopping ch_id:%d\n", ch->ch_id); } } @@ -2742,7 +2759,7 @@ static int mhi_dev_cache_host_cfg(struct mhi_dev *mhi) /* Get Channel, event and command context base pointer */ rc = mhi_dev_mmio_get_chc_base(mhi); if (rc) { - mhi_log(MHI_MSG_ERROR, "Fetching channel context failed\n"); + mhi_log(MHI_MSG_ERROR, "Fetching ch context failed\n"); return rc; } @@ -3114,7 +3131,7 @@ static int mhi_dev_alloc_evt_buf_evt_req(struct mhi_dev *mhi, if (!size) { mhi_log(MHI_MSG_ERROR, - "Evt buf size is 0 for channel %d", ch->ch_id); + "Evt buf size is 0 for ch_id:%d", ch->ch_id); return -EINVAL; } @@ -3139,13 +3156,13 @@ static int mhi_dev_alloc_evt_buf_evt_req(struct mhi_dev *mhi, ch->evt_req_size = size; mhi_log(MHI_MSG_INFO, - "Channel %d evt buf size is %d\n", ch->ch_id, ch->evt_buf_size); + "ch_id:%d evt buf size is %d\n", ch->ch_id, ch->evt_buf_size); /* Allocate event requests */ ch->ereqs = kcalloc(ch->evt_req_size, sizeof(*ch->ereqs), GFP_KERNEL); if (!ch->ereqs) { mhi_log(MHI_MSG_ERROR, - "Failed to alloc ereqs for Channel %d\n", ch->ch_id); + "Failed to alloc ereqs for ch_id:%d\n", ch->ch_id); rc = -ENOMEM; goto free_ereqs; } @@ -3155,7 +3172,7 @@ static int mhi_dev_alloc_evt_buf_evt_req(struct mhi_dev *mhi, GFP_KERNEL); if (!ch->tr_events) { mhi_log(MHI_MSG_ERROR, - "Failed to alloc tr_events buffer for Channel %d\n", + "Failed to alloc tr_events buffer for ch_id:%d\n", ch->ch_id); rc = -ENOMEM; goto free_ereqs; @@ -3212,7 +3229,7 @@ int mhi_dev_open_channel(uint32_t chan_id, if (ch->active_client) { mhi_log(MHI_MSG_ERROR, - "Channel (%d) already opened by client\n", chan_id); + "ch_id:%d already opened by client\n", chan_id); rc = -EINVAL; goto exit; } @@ -3260,7 +3277,7 @@ int mhi_dev_channel_isempty(struct mhi_dev_client *handle) int rc; if (!handle) { - mhi_log(MHI_MSG_ERROR, "Invalid channel access\n"); + mhi_log(MHI_MSG_ERROR, "Invalid ch access\n"); return -EINVAL; } @@ -3279,7 +3296,7 @@ bool mhi_dev_channel_has_pending_write(struct mhi_dev_client *handle) struct mhi_dev_channel *ch; if (!handle) { - mhi_log(MHI_MSG_ERROR, "Invalid channel access\n"); + mhi_log(MHI_MSG_ERROR, "Invalid ch access\n"); return -EINVAL; } @@ -3298,7 +3315,7 @@ void mhi_dev_close_channel(struct mhi_dev_client *handle) int rc = 0; struct event_req *itr, *tmp; if (!handle) { - mhi_log(MHI_MSG_ERROR, "Invalid channel access:%d\n", -ENODEV); + mhi_log(MHI_MSG_ERROR, "Invalid ch access:%d\n", -ENODEV); return; } ch = handle->channel; @@ -3319,17 +3336,17 @@ void mhi_dev_close_channel(struct mhi_dev_client *handle) } while (++count < MHI_DEV_CH_CLOSE_TIMEOUT_COUNT); if (ch->pend_wr_count) - mhi_log(MHI_MSG_ERROR, "%d writes pending for channel %d\n", + mhi_log(MHI_MSG_ERROR, "%d writes pending for ch_id:%d\n", ch->pend_wr_count, ch->ch_id); if (!list_empty(&ch->event_req_buffers)) - mhi_log(MHI_MSG_ERROR, "%d pending flush for channel %d\n", + mhi_log(MHI_MSG_ERROR, "%d pending flush for ch_id:%d\n", ch->pend_wr_count, ch->ch_id); if (ch->state != MHI_DEV_CH_PENDING_START) if ((ch->ch_type == MHI_DEV_CH_TYPE_OUTBOUND_CHANNEL && !mhi_dev_channel_isempty(handle)) || ch->tre_loc) mhi_log(MHI_MSG_DBG, - "Trying to close an active channel (%d)\n", + "Trying to close an active ch_id:%d\n", ch->ch_id); if (!list_empty(&ch->flush_event_req_buffers)) { @@ -3401,7 +3418,7 @@ int mhi_dev_read_channel(struct mhi_req *mreq) if (mhi_ctx->ctrl_info != MHI_STATE_CONNECTED) { mhi_log(MHI_MSG_ERROR, - "Channel not connected:%d\n", mhi_ctx->ctrl_info); + "ch not connected:%d\n", mhi_ctx->ctrl_info); return -ENODEV; } @@ -3412,7 +3429,7 @@ int mhi_dev_read_channel(struct mhi_req *mreq) if (atomic_read(&mhi_ctx->is_suspended)) { mhi_log(MHI_MSG_ERROR, - "mhi still in suspend, return %d for read ch:%d\n", + "mhi still in suspend, return %d for read ch_id:%d\n", rc, mreq->client->channel->ch_id); return -ENODEV; } @@ -3428,7 +3445,7 @@ int mhi_dev_read_channel(struct mhi_req *mreq) do { if (ch->state == MHI_DEV_CH_STOPPED || ch->reset_pending) { mhi_log(MHI_MSG_VERBOSE, - "channel (%d) already stopped or RST pending\n", + "ch_id:%d already stopped or RST pending\n", mreq->chan); bytes_read = -1; goto exit; @@ -3475,13 +3492,13 @@ int mhi_dev_read_channel(struct mhi_req *mreq) mreq->el = el; mreq->transfer_len = bytes_to_read; mreq->rd_offset = ring->rd_offset; - mhi_log(MHI_MSG_VERBOSE, "reading %lu bytes from chan %d\n", + mhi_log(MHI_MSG_VERBOSE, "reading %lu bytes from ch_id:%d\n", bytes_to_read, mreq->chan); rc = mhi_ctx->host_to_device((void *) write_to_loc, read_from_loc, bytes_to_read, mhi_ctx, mreq); if (rc) { mhi_log(MHI_MSG_ERROR, - "Error while reading chan (%d) rc %d\n", + "Error while reading ch_id:%d rc %d\n", mreq->chan, rc); mutex_unlock(&ch->ch_lock); return rc; @@ -3502,7 +3519,7 @@ int mhi_dev_read_channel(struct mhi_req *mreq) rc = mhi_dev_process_stop_cmd(ring, mreq->chan, mhi_ctx); if (rc) { mhi_log(MHI_MSG_ERROR, - "Error while stopping channel (%d)\n", + "Error while stopping ch_id:%d\n", mreq->chan); bytes_read = -EIO; } @@ -3559,7 +3576,7 @@ int mhi_dev_write_channel(struct mhi_req *wreq) if (mhi_ctx->ctrl_info != MHI_STATE_CONNECTED) { mhi_log(MHI_MSG_ERROR, - "Channel not connected:%d\n", mhi_ctx->ctrl_info); + "ch not connected:%d\n", mhi_ctx->ctrl_info); return -ENODEV; } @@ -3574,7 +3591,7 @@ int mhi_dev_write_channel(struct mhi_req *wreq) * to the MHI core -> notify SM. */ mutex_lock(&mhi_ctx->mhi_lock); - mhi_log(MHI_MSG_CRITICAL, "Wakeup by chan:%d\n", ch->ch_id); + mhi_log(MHI_MSG_CRITICAL, "Wakeup by ch_id:%d\n", ch->ch_id); rc = mhi_dev_notify_sm_event(MHI_DEV_EVENT_CORE_WAKEUP); if (rc) { mhi_log(MHI_MSG_ERROR, @@ -3607,7 +3624,7 @@ int mhi_dev_write_channel(struct mhi_req *wreq) rc = mhi_ctrl_state_info(ch->ch_id, &info); if (rc || (info != MHI_STATE_CONNECTED)) { - mhi_log(MHI_MSG_ERROR, "Channel %d not started by host\n", + mhi_log(MHI_MSG_ERROR, "ch_id %d not started by host\n", ch->ch_id); mutex_unlock(&ch->ch_lock); mutex_unlock(&mhi_ctx->mhi_write_test); @@ -3617,7 +3634,7 @@ int mhi_dev_write_channel(struct mhi_req *wreq) ch->pend_wr_count++; if (ch->state == MHI_DEV_CH_STOPPED || ch->reset_pending) { mhi_log(MHI_MSG_ERROR, - "channel %d already stopped or RST pending\n", + "ch_id:%d already stopped or RST pending\n", wreq->chan); bytes_written = -1; goto exit; @@ -3635,7 +3652,7 @@ int mhi_dev_write_channel(struct mhi_req *wreq) do { if (ring->rd_offset == ring->wr_offset) { mhi_log(MHI_MSG_ERROR, - "rd & wr offsets are equal for channel-id %d\n", + "rd & wr offsets are equal for ch_id:%d\n", wreq->chan); mhi_log(MHI_MSG_INFO, "No TREs available\n"); break; @@ -3664,7 +3681,7 @@ int mhi_dev_write_channel(struct mhi_req *wreq) mhi_ctx, wreq); if (rc) { mhi_log(MHI_MSG_ERROR, - "Error while writing chan (%d) rc %d\n", + "Error while writing ch_id:%d rc %d\n", wreq->chan, rc); goto exit; } else if (wreq->mode == DMA_ASYNC) @@ -3687,7 +3704,7 @@ int mhi_dev_write_channel(struct mhi_req *wreq) ring->rd_offset, bytes_to_write, code); if (rc) { mhi_log(MHI_MSG_VERBOSE, - "err in snding cmpl evt ch:%d\n", + "err in snding cmpl evt ch_id:%d\n", wreq->chan); } mhi_dev_ring_inc_index(ring, ring->rd_offset); @@ -3705,7 +3722,7 @@ int mhi_dev_write_channel(struct mhi_req *wreq) rc = mhi_dev_process_stop_cmd(ring, wreq->chan, mhi_ctx); if (rc) { mhi_log(MHI_MSG_ERROR, - "channel %d stop failed\n", wreq->chan); + "ch_id:%d stop failed\n", wreq->chan); } } exit: @@ -3930,7 +3947,7 @@ int mhi_register_state_cb(void (*mhi_state_cb) return -ENXIO; if (channel >= MHI_MAX_SOFTWARE_CHANNELS) { - mhi_log(MHI_MSG_ERROR, "Invalid channel :%d\n", channel); + mhi_log(MHI_MSG_ERROR, "Invalid ch_id:%d\n", channel); return -EINVAL; } @@ -4492,20 +4509,20 @@ static int mhi_edma_init(struct device *dev) mhi_ctx->tx_dma_chan = dma_request_slave_channel(dev, "tx"); if (IS_ERR_OR_NULL(mhi_ctx->tx_dma_chan)) { mhi_log(MHI_MSG_ERROR, - "request for TX chan failed\n"); + "request for TX ch failed\n"); return -EIO; } - mhi_log(MHI_MSG_VERBOSE, "request for TX chan returned :%pK\n", + mhi_log(MHI_MSG_VERBOSE, "request for TX ch returned :%pK\n", mhi_ctx->tx_dma_chan); mhi_ctx->rx_dma_chan = dma_request_slave_channel(dev, "rx"); if (IS_ERR_OR_NULL(mhi_ctx->rx_dma_chan)) { mhi_log(MHI_MSG_ERROR, - "request for RX chan failed\n"); + "request for RX ch failed\n"); return -EIO; } - mhi_log(MHI_MSG_VERBOSE, "request for RX chan returned :%pK\n", + mhi_log(MHI_MSG_VERBOSE, "request for RX ch returned :%pK\n", mhi_ctx->rx_dma_chan); return 0; } diff --git a/drivers/platform/msm/mhi_dev/mhi_dev_net.c b/drivers/platform/msm/mhi_dev/mhi_dev_net.c index ac236edfe928..d05bbe5f1f4f 100644 --- a/drivers/platform/msm/mhi_dev/mhi_dev_net.c +++ b/drivers/platform/msm/mhi_dev/mhi_dev_net.c @@ -121,7 +121,7 @@ static int mhi_dev_net_init_ch_attributes(struct mhi_dev_net_ctxt *mhi_ctxt) chan_attrib->dir = MHI_DIR_OUT; chan_attrib->chan_id = channel; chan_attrib->max_packet_size = TRB_MAX_DATA_SIZE; - mhi_dev_net_log(MHI_INFO, "Write chan attributes dir %d chan_id %d\n", + mhi_dev_net_log(MHI_INFO, "Write ch attributes dir %d ch_id:%d\n", chan_attrib->dir, chan_attrib->chan_id); channel = MHI_CLIENT_IP_SW_4_IN; @@ -129,7 +129,7 @@ static int mhi_dev_net_init_ch_attributes(struct mhi_dev_net_ctxt *mhi_ctxt) chan_attrib->dir = MHI_DIR_IN; chan_attrib->chan_id = channel; chan_attrib->max_packet_size = TRB_MAX_DATA_SIZE; - mhi_dev_net_log(MHI_INFO, "Read chan attributes dir %d chan_id %d\n", + mhi_dev_net_log(MHI_INFO, "Read ch attributes dir %d ch_id %d\n", chan_attrib->dir, chan_attrib->chan_id); return 0; } @@ -299,7 +299,7 @@ static ssize_t mhi_dev_net_client_read(struct mhi_dev_net_client *mhi_handle) if (bytes_avail < 0) { mhi_dev_net_log(MHI_ERROR, - "Failed to read chan %d bytes_avail = %d\n", + "Failed to read ch_id:%d bytes_avail = %d\n", chan, bytes_avail); spin_lock_irqsave(&mhi_handle->rd_lock, flags); kfree_skb(skb); @@ -513,18 +513,18 @@ static int mhi_dev_net_open_chan_create_netif(struct mhi_dev_net_client *client) struct list_head *cp, *q; struct mhi_req *mreq; - mhi_dev_net_log(MHI_DBG, "opening OUT %d IN %d channels\n", + mhi_dev_net_log(MHI_DBG, "opening OUT ch_id:%d IN ch_id:%d channels\n", client->out_chan, client->in_chan); mhi_dev_net_log(MHI_DBG, - "Initializing inbound chan %d.\n", + "Initializing inbound ch_id:%d.\n", client->in_chan); rc = mhi_dev_open_channel(client->out_chan, &client->out_handle, mhi_net_ctxt.net_event_notifier); if (rc < 0) { mhi_dev_net_log(MHI_ERROR, - "Failed to open chan %d, ret 0x%x\n", + "Failed to open ch_id:%d, ret 0x%x\n", client->out_chan, rc); goto handle_not_rdy_err; } else @@ -534,13 +534,13 @@ static int mhi_dev_net_open_chan_create_netif(struct mhi_dev_net_client *client) mhi_net_ctxt.net_event_notifier); if (rc < 0) { mhi_dev_net_log(MHI_ERROR, - "Failed to open chan %d, ret 0x%x\n", + "Failed to open ch_id:%d, ret 0x%x\n", client->in_chan, rc); goto handle_in_err; } else atomic_set(&client->tx_enabled, 1); - mhi_dev_net_log(MHI_INFO, "IN %d, OUT %d channels are opened", + mhi_dev_net_log(MHI_INFO, "IN ch_id:%d, OUT ch_id:%d channels are opened", client->in_chan, client->out_chan); INIT_LIST_HEAD(&client->rx_buffers); @@ -612,7 +612,8 @@ static int mhi_dev_net_rgstr_client(struct mhi_dev_net_client *client, int idx) mutex_init(&client->out_chan_lock); spin_lock_init(&client->wrt_lock); spin_lock_init(&client->rd_lock); - mhi_dev_net_log(MHI_INFO, "Registering out %d, In %d channels\n", + mhi_dev_net_log(MHI_INFO, "Registering OUT ch_id:%d\t" + "IN ch_id:%d channels\n", client->out_chan, client->in_chan); return 0; } @@ -653,20 +654,20 @@ static void mhi_dev_net_state_cb(struct mhi_dev_client_cb_data *cb_data) ret = mhi_ctrl_state_info(mhi_client->in_chan, &info_in_ch); if (ret) { mhi_dev_net_log(MHI_ERROR, - "Failed to obtain in_channel %d state\n", + "Failed to obtain IN ch_id:%d state\n", mhi_client->in_chan); return; } ret = mhi_ctrl_state_info(mhi_client->out_chan, &info_out_ch); if (ret) { mhi_dev_net_log(MHI_ERROR, - "Failed to obtain out_channel %d state\n", + "Failed to obtain OUT ch_id:%d state\n", mhi_client->out_chan); return; } - mhi_dev_net_log(MHI_MSG_VERBOSE, "in_channel :%d, state :%d\n", + mhi_dev_net_log(MHI_MSG_VERBOSE, "IN ch_id::%d, state :%d\n", mhi_client->in_chan, info_in_ch); - mhi_dev_net_log(MHI_MSG_VERBOSE, "out_channel :%d, state :%d\n", + mhi_dev_net_log(MHI_MSG_VERBOSE, "OUT ch_id:%d, state :%d\n", mhi_client->out_chan, info_out_ch); if (info_in_ch == MHI_STATE_CONNECTED && info_out_ch == MHI_STATE_CONNECTED) { diff --git a/drivers/platform/msm/mhi_dev/mhi_mmio.c b/drivers/platform/msm/mhi_dev/mhi_mmio.c index 44f64b679cb5..a306b58511c1 100644 --- a/drivers/platform/msm/mhi_dev/mhi_mmio.c +++ b/drivers/platform/msm/mhi_dev/mhi_mmio.c @@ -101,7 +101,7 @@ static int mhi_dev_mmio_mask_set_chdb_int_a7(struct mhi_dev *dev, chid_idx = chdb_id/32; if (chid_idx >= MHI_MASK_ROWS_CH_EV_DB) { - mhi_log(MHI_MSG_ERROR, "Invalid channel id:%d\n", chid_idx); + mhi_log(MHI_MSG_ERROR, "Invalid ch_id:%d\n", chid_idx); return -EINVAL; } diff --git a/drivers/platform/msm/mhi_dev/mhi_ring.c b/drivers/platform/msm/mhi_dev/mhi_ring.c index 9ef1134c0eca..06d18c81e9ce 100644 --- a/drivers/platform/msm/mhi_dev/mhi_ring.c +++ b/drivers/platform/msm/mhi_dev/mhi_ring.c @@ -94,7 +94,7 @@ int mhi_dev_cache_ring(struct mhi_dev_ring *ring, size_t wr_offset) if (ring->wr_offset == wr_offset) { mhi_log(MHI_MSG_VERBOSE, - "nothing to cache for ring %d, local wr_ofst %lu\n", + "nothing to cache for ring_id:%d, local wr_ofst %lu\n", ring->id, ring->wr_offset); mhi_log(MHI_MSG_VERBOSE, "new wr_offset %lu\n", wr_offset); @@ -112,16 +112,16 @@ int mhi_dev_cache_ring(struct mhi_dev_ring *ring, size_t wr_offset) ring->id < (mhi_ctx->ev_ring_start + mhi_ctx->cfg.event_rings)) { mhi_log(MHI_MSG_VERBOSE, - "not caching event ring %d\n", ring->id); + "not caching event ring_id:%d\n", ring->id); return 0; } - mhi_log(MHI_MSG_VERBOSE, "caching ring %d, start %lu, end %lu\n", + mhi_log(MHI_MSG_VERBOSE, "caching ring_id:%d, start %lu, end %lu\n", ring->id, old_offset, wr_offset); if (mhi_dev_fetch_ring_elements(ring, old_offset, wr_offset)) { mhi_log(MHI_MSG_ERROR, - "failed to fetch elements for ring %d, start %lu, end %lu\n", + "failed to fetch elements for ring_id:%d, start %lu, end %lu\n", ring->id, old_offset, wr_offset); return -EINVAL; } @@ -147,7 +147,7 @@ int mhi_dev_update_wr_offset(struct mhi_dev_ring *ring) return rc; } mhi_log(MHI_MSG_VERBOSE, - "ring %d wr_offset from db 0x%lx\n", + "ring_id:%d wr_offset from db 0x%lx\n", ring->id, (size_t) wr_offset); break; case RING_TYPE_ER: @@ -164,7 +164,7 @@ int mhi_dev_update_wr_offset(struct mhi_dev_ring *ring) return rc; } mhi_log(MHI_MSG_VERBOSE, - "ring %d wr_offset from db 0x%lx\n", + "ring_id:%d wr_offset from db 0x%lx\n", ring->id, (size_t) wr_offset); break; default: @@ -202,7 +202,7 @@ int mhi_dev_process_ring_element(struct mhi_dev_ring *ring, size_t offset) if (ring->ring_cb) return ring->ring_cb(ring->mhi_dev, el, (void *)ring); else - mhi_log(MHI_MSG_ERROR, "No callback registered for ring %d\n", + mhi_log(MHI_MSG_ERROR, "No callback registered for ring_id:%d\n", ring->id); return 0; @@ -217,19 +217,19 @@ int mhi_dev_process_ring(struct mhi_dev_ring *ring) return -EINVAL; mhi_log(MHI_MSG_VERBOSE, - "Before wr update ring_id (%d) rp:%lu wp:%lu\n", + "Before wr update ring_id:%d rp:%lu wp:%lu\n", ring->id, ring->rd_offset, ring->wr_offset); rc = mhi_dev_update_wr_offset(ring); if (rc) { mhi_log(MHI_MSG_ERROR, - "Error updating write-offset for ring %d\n", + "Error updating write-offset for ring_id:%d\n", ring->id); return rc; } mhi_log(MHI_MSG_VERBOSE, - "After wp update ring_id (%d) rp:%lu with wr:%lu\n", + "After wp update ring_id:%d rp:%lu with wr:%lu\n", ring->id, ring->rd_offset, ring->wr_offset); /* @@ -247,13 +247,13 @@ int mhi_dev_process_ring(struct mhi_dev_ring *ring) while (ring->rd_offset != ring->wr_offset) { mhi_log(MHI_MSG_VERBOSE, - "Processing ring (%d) rd_offset:%lu, wr_offset:%lu\n", + "Processing ring_id:%d rd_offset:%lu, wr_offset:%lu\n", ring->id, ring->rd_offset, ring->wr_offset); rc = mhi_dev_process_ring_element(ring, ring->rd_offset); if (rc) { mhi_log(MHI_MSG_ERROR, - "Error processing ring (%d) element(rp) (%lu)\n", + "Error processing ring_id:%d element(rp):%lu\n", ring->id, ring->rd_offset); return rc; } @@ -298,7 +298,7 @@ int mhi_dev_add_element(struct mhi_dev_ring *ring, ring->wr_offset - 1; if (num_free_elem < num_elem) { - mhi_log(MHI_MSG_ERROR, "No space to add %d elem in ring (%d)\n", + mhi_log(MHI_MSG_ERROR, "No space to add %d elem in ring_id:%d\n", num_elem, ring->id); return -EINVAL; } @@ -313,8 +313,9 @@ int mhi_dev_add_element(struct mhi_dev_ring *ring, mhi_dev_ring_inc_index(ring, ring->rd_offset); mhi_log(MHI_MSG_VERBOSE, - "Writing %d elements, ring old 0x%x, new 0x%x\n", - num_elem, old_offset, ring->rd_offset); + "Writing %d elements in ring_id:%d\t" + "ring old-offset 0x%x, new-offset 0x%x\n", + num_elem, ring->id, old_offset, ring->rd_offset); ring->ring_ctx->generic.rp = (ring->rd_offset * sizeof(union mhi_dev_ring_element_type)) + @@ -336,7 +337,7 @@ int mhi_dev_add_element(struct mhi_dev_ring *ring, host_addr.virt_addr = element; host_addr.size = sizeof(union mhi_dev_ring_element_type); - mhi_log(MHI_MSG_VERBOSE, "adding element to ring (%d)\n", + mhi_log(MHI_MSG_VERBOSE, "adding element to ring_id:%d\n", ring->id); mhi_log(MHI_MSG_VERBOSE, "rd_ofset %lu\n", ring->rd_offset); mhi_log(MHI_MSG_VERBOSE, "type %d\n", element->generic.type); @@ -356,7 +357,7 @@ int mhi_dev_add_element(struct mhi_dev_ring *ring, (element + i)->evt_tr_comp.code); mhi_log(MHI_MSG_VERBOSE, "evnt type :0x%x\n", (element + i)->evt_tr_comp.type); - mhi_log(MHI_MSG_VERBOSE, "evnt chid :0x%x\n", + mhi_log(MHI_MSG_VERBOSE, "evnt ch_id :0x%x\n", (element + i)->evt_tr_comp.chid); } /* Adding multiple ring elements */ diff --git a/drivers/platform/msm/mhi_dev/mhi_uci.c b/drivers/platform/msm/mhi_dev/mhi_uci.c index 2b458e130201..53ddfc75ab42 100644 --- a/drivers/platform/msm/mhi_dev/mhi_uci.c +++ b/drivers/platform/msm/mhi_dev/mhi_uci.c @@ -452,7 +452,7 @@ static bool mhi_uci_are_channels_connected(struct uci_client *uci_client) rc = mhi_ctrl_state_info(uci_client->in_chan, &info_ch_in); if (rc) { uci_log(UCI_DBG_DBG, - "Channels %d is not available with %d\n", + "ch_id:%d is not available with %d\n", uci_client->out_chan, rc); return false; } @@ -460,7 +460,7 @@ static bool mhi_uci_are_channels_connected(struct uci_client *uci_client) rc = mhi_ctrl_state_info(uci_client->out_chan, &info_ch_out); if (rc) { uci_log(UCI_DBG_DBG, - "Channels %d is not available with %d\n", + "ch_id:%d is not available with %d\n", uci_client->out_chan, rc); return false; } @@ -468,7 +468,7 @@ static bool mhi_uci_are_channels_connected(struct uci_client *uci_client) if ((info_ch_in != MHI_STATE_CONNECTED) || (info_ch_out != MHI_STATE_CONNECTED)) { uci_log(UCI_DBG_DBG, - "Channels %d or %d are not connected\n", + "ch_id:%d or %d are not connected\n", uci_client->in_chan, uci_client->out_chan); return false; } @@ -490,13 +490,13 @@ static int mhi_init_read_chan(struct uci_client *client_handle, return -EINVAL; } if (chan >= MHI_MAX_SOFTWARE_CHANNELS) { - uci_log(UCI_DBG_ERROR, "Incorrect channel number %d\n", chan); + uci_log(UCI_DBG_ERROR, "Incorrect ch_id:%d\n", chan); return -EINVAL; } in_chan_attr = client_handle->in_chan_attr; if (!in_chan_attr) { - uci_log(UCI_DBG_ERROR, "Null channel attributes for chan %d\n", + uci_log(UCI_DBG_ERROR, "Null channel attributes for ch_id:%d\n", client_handle->in_chan); return -EINVAL; } @@ -531,7 +531,7 @@ static struct mhi_req *mhi_uci_get_req(struct uci_client *uci_handle) spin_lock_irqsave(&uci_handle->req_lock, flags); if (list_empty(&uci_handle->req_list)) { - uci_log(UCI_DBG_ERROR, "Request pool empty for chans %d, %d\n", + uci_log(UCI_DBG_ERROR, "Request pool empty for ch_id:%d, %d\n", uci_handle->in_chan, uci_handle->out_chan); spin_unlock_irqrestore(&uci_handle->req_lock, flags); return NULL; @@ -546,7 +546,7 @@ static struct mhi_req *mhi_uci_get_req(struct uci_client *uci_handle) * req is re-used */ if (req->is_stale && req->buf && MHI_UCI_IS_CHAN_DIR_IN(req->chan)) { - uci_log(UCI_DBG_VERBOSE, "Freeing write buf for chan %d\n", + uci_log(UCI_DBG_VERBOSE, "Freeing write buf for ch_id:%d\n", req->chan); kfree(req->buf); } @@ -565,7 +565,7 @@ static int mhi_uci_put_req(struct uci_client *uci_handle, struct mhi_req *req) spin_lock_irqsave(&uci_handle->req_lock, flags); if (req->is_stale) { uci_log(UCI_DBG_VERBOSE, - "Got stale completion for ch %d, ignoring\n", + "Got stale completion for ch_id:%d, ignoring\n", req->chan); spin_unlock_irqrestore(&uci_handle->req_lock, flags); return -EINVAL; @@ -630,7 +630,8 @@ static int mhi_uci_send_sync(struct uci_client *uci_handle, int ret_val; uci_log(UCI_DBG_VERBOSE, - "Sync write for ch %d size %d\n", uci_handle->out_chan, size); + "Sync write for ch_id:%d size %d\n", + uci_handle->out_chan, size); ureq.client = uci_handle->out_handle; ureq.buf = data_loc; @@ -652,7 +653,7 @@ static int mhi_uci_send_async(struct uci_client *uci_handle, struct mhi_req *ureq; uci_log(UCI_DBG_DBG, - "Async write for ch %d size %d\n", + "Async write for ch_id:%d size %d\n", uci_handle->out_chan, size); ureq = mhi_uci_get_req(uci_handle); @@ -691,7 +692,7 @@ static int mhi_uci_send_packet(struct uci_client *uci_handle, void *data_loc, ret_val = uci_handle->send(uci_handle, data_loc, size); if (!ret_val) { uci_log(UCI_DBG_VERBOSE, - "No descriptors available, did we poll, chan %d?\n", + "No descriptors available, did we poll, ch_id:%d?\n", uci_handle->out_chan); mutex_unlock(&uci_handle->out_chan_lock); if (uci_handle->f_flags & (O_NONBLOCK | O_NDELAY)) @@ -711,7 +712,7 @@ static int mhi_uci_send_packet(struct uci_client *uci_handle, void *data_loc, * Wait till pending writes complete or a timeout. */ uci_log(UCI_DBG_VERBOSE, - "Write req list empty for chan %d\n", + "Write req list empty for ch_id:%d\n", uci_handle->out_chan); mutex_unlock(&uci_handle->out_chan_lock); if (uci_handle->f_flags & (O_NONBLOCK | O_NDELAY)) @@ -726,14 +727,14 @@ static int mhi_uci_send_packet(struct uci_client *uci_handle, void *data_loc, * retry the write. */ uci_log(UCI_DBG_VERBOSE, - "Write req struct available for chan %d\n", + "Write req struct available for ch_id:%d\n", uci_handle->out_chan); mutex_lock(&uci_handle->out_chan_lock); ret_val = 0; continue; } else if (!ret_val) { uci_log(UCI_DBG_ERROR, - "Timed out waiting for write req, chan %d\n", + "Timed out waiting for write req, ch_id:%d\n", uci_handle->out_chan); return -EIO; } else if (-ERESTARTSYS == ret_val) { @@ -743,7 +744,7 @@ static int mhi_uci_send_packet(struct uci_client *uci_handle, void *data_loc, } } else if (ret_val < 0) { uci_log(UCI_DBG_ERROR, - "Err sending data: chan %d, buf %pK, size %d\n", + "Err sending data: ch_id:%d, buf %pK, size %d\n", uci_handle->out_chan, data_loc, size); ret_val = -EIO; break; @@ -807,18 +808,18 @@ static unsigned int mhi_uci_client_poll(struct file *file, poll_table *wait) if (!atomic_read(&uci_ctxt.mhi_disabled) && !mhi_dev_channel_isempty(uci_handle->in_handle)) { uci_log(UCI_DBG_VERBOSE, - "Client can read chan %d\n", uci_handle->in_chan); + "Client can read ch_id:%d\n", uci_handle->in_chan); mask |= POLLIN | POLLRDNORM; } if (!atomic_read(&uci_ctxt.mhi_disabled) && !mhi_dev_channel_isempty(uci_handle->out_handle)) { uci_log(UCI_DBG_VERBOSE, - "Client can write chan %d\n", uci_handle->out_chan); + "Client can write ch_id:%d\n", uci_handle->out_chan); mask |= POLLOUT | POLLWRNORM; } uci_log(UCI_DBG_VERBOSE, - "Client attempted to poll chan %d, returning mask 0x%x\n", + "Client attempted to poll ch_id:%d, returning mask 0x%x\n", uci_handle->in_chan, mask); mutex_unlock(&uci_handle->client_lock); @@ -853,7 +854,7 @@ static int mhi_uci_alloc_reqs(struct uci_client *client) list_add_tail(&client->reqs[i].list, &client->req_list); uci_log(UCI_DBG_INFO, - "Allocated %d write reqs for chan %d\n", + "Allocated %d write reqs for ch_id:%d\n", num_reqs, client->out_chan); return 0; } @@ -866,12 +867,12 @@ static int mhi_uci_read_async(struct uci_client *uci_handle, int *bytes_avail) struct mhi_dev_client *client_handle; uci_log(UCI_DBG_DBG, - "Async read for ch %d\n", uci_handle->in_chan); + "Async read for ch_id:%d\n", uci_handle->in_chan); ureq = mhi_uci_get_req(uci_handle); if (!ureq) { uci_log(UCI_DBG_ERROR, - "Out of reqs for chan %d\n", uci_handle->in_chan); + "Out of reqs for ch_id:%d\n", uci_handle->in_chan); return -EBUSY; } @@ -917,14 +918,14 @@ static int mhi_uci_read_async(struct uci_client *uci_handle, int *bytes_avail) uci_log(UCI_DBG_ERROR, "Exit signal caught\n"); return compl_ret; } else if (compl_ret == 0) { - uci_log(UCI_DBG_ERROR, "Read timed out for ch %d\n", + uci_log(UCI_DBG_ERROR, "Read timed out for ch_id:%d\n", uci_handle->in_chan); return -EIO; } uci_log(UCI_DBG_VERBOSE, - "wk up Read completed on ch %d\n", uci_handle->in_chan); + "wk up Read completed on ch_id:%d\n", uci_handle->in_chan); uci_log(UCI_DBG_VERBOSE, - "Got pkt of sz 0x%lx at adr %pK, ch %d\n", + "Got pkt of sz 0x%lx at adr %pK, ch_id:%d\n", uci_handle->pkt_size, uci_handle->pkt_loc, uci_handle->in_chan); } else { @@ -945,7 +946,7 @@ static int mhi_uci_read_sync(struct uci_client *uci_handle, int *bytes_avail) struct mhi_dev_client *client_handle; uci_log(UCI_DBG_INFO, - "Sync read for ch %d\n", uci_handle->in_chan); + "Sync read for ch_id:%d\n", uci_handle->in_chan); client_handle = uci_handle->in_handle; ureq.chan = uci_handle->in_chan; @@ -969,7 +970,7 @@ static int mhi_uci_read_sync(struct uci_client *uci_handle, int *bytes_avail) uci_handle->pkt_size = ureq.transfer_len; uci_log(UCI_DBG_VERBOSE, - "Got pkt of sz 0x%lx at adr %pK, ch %d\n", + "Got pkt of sz 0x%lx at adr %pK, ch_id:%d\n", uci_handle->pkt_size, ureq.buf, ureq.chan); } else { @@ -990,7 +991,7 @@ static int open_client_mhi_channels(struct uci_client *uci_client) } uci_log(UCI_DBG_DBG, - "Starting channels %d %d.\n", + "Starting channels OUT ch_id:%d IN ch_id:%d\n", uci_client->out_chan, uci_client->in_chan); mutex_lock(&uci_client->out_chan_lock); @@ -1009,7 +1010,7 @@ static int open_client_mhi_channels(struct uci_client *uci_client) } uci_log(UCI_DBG_DBG, - "Initializing inbound chan %d.\n", + "Initializing inbound ch_id:%d.\n", uci_client->in_chan); rc = mhi_init_read_chan(uci_client, uci_client->in_chan); if (rc < 0) { @@ -1030,7 +1031,7 @@ static int open_client_mhi_channels(struct uci_client *uci_client) uci_ctxt.event_notifier); if (rc < 0) { uci_log(UCI_DBG_ERROR, - "Failed to open chan %d, ret %d\n", + "Failed to open ch_id:%d, ret %d\n", uci_client->out_chan, rc); goto handle_in_err; } @@ -1133,14 +1134,14 @@ static int mhi_uci_client_release(struct inode *mhi_inode, mutex_lock(&uci_handle->client_lock); in_chan_attr = uci_handle->in_chan_attr; if (!in_chan_attr) { - uci_log(UCI_DBG_ERROR, "Null channel attributes for chan %d\n", + uci_log(UCI_DBG_ERROR, "Null channel attributes for ch_id:%d\n", uci_handle->in_chan); mutex_unlock(&uci_handle->client_lock); return -EINVAL; } if (atomic_sub_return(1, &uci_handle->ref_count)) { - uci_log(UCI_DBG_DBG, "Client close chan %d, ref count 0x%x\n", + uci_log(UCI_DBG_DBG, "Client close ch_id:%d, ref count 0x%x\n", iminor(mhi_inode), atomic_read(&uci_handle->ref_count)); mutex_unlock(&uci_handle->client_lock); @@ -1148,7 +1149,7 @@ static int mhi_uci_client_release(struct inode *mhi_inode, } uci_log(UCI_DBG_DBG, - "Last client left, closing channel 0x%x\n", + "Last client left, closing ch 0x%x\n", iminor(mhi_inode)); do { @@ -1160,7 +1161,7 @@ static int mhi_uci_client_release(struct inode *mhi_inode, } while (++count < MHI_UCI_RELEASE_TIMEOUT_COUNT); if (count == MHI_UCI_RELEASE_TIMEOUT_COUNT) { - uci_log(UCI_DBG_DBG, "Channel %d has pending writes\n", + uci_log(UCI_DBG_DBG, "ch_id:%d has pending writes\n", iminor(mhi_inode)); } @@ -1191,7 +1192,7 @@ static int mhi_uci_client_release(struct inode *mhi_inode, list_del_init(&ureq->list); ureq->is_stale = true; uci_log(UCI_DBG_VERBOSE, - "Adding back req for chan %d to free list\n", + "Adding back req for ch_id:%d to free list\n", ureq->chan); list_add_tail(&ureq->list, &uci_handle->req_list); count++; @@ -1256,12 +1257,12 @@ static int mhi_state_uevent(struct device *dev, struct kobj_uevent_env *env) for (i = 0; i < ARRAY_SIZE(mhi_chan_attr_table); i++) { chan_attrib = &mhi_chan_attr_table[i]; if (chan_attrib->state_bcast) { - uci_log(UCI_DBG_INFO, "Calling notify for ch %d\n", + uci_log(UCI_DBG_INFO, "Calling notify for ch_id:%d\n", chan_attrib->chan_id); rc = mhi_ctrl_state_info(chan_attrib->chan_id, &info); if (rc) { uci_log(UCI_DBG_ERROR, - "Failed to obtain channel %d state\n", + "Failed to obtain ch_id:%d state\n", chan_attrib->chan_id); return -EINVAL; } @@ -1343,7 +1344,7 @@ static int __mhi_uci_client_read(struct uci_client *uci_handle, /* If nothing was copied yet, wait for data */ uci_log(UCI_DBG_VERBOSE, - "No data read_data_ready %d, chan %d\n", + "No data read_data_ready %d, ch_id:%d\n", atomic_read(&uci_handle->read_data_ready), uci_handle->in_chan); if (uci_handle->f_flags & (O_NONBLOCK | O_NDELAY)) @@ -1359,13 +1360,13 @@ static int __mhi_uci_client_read(struct uci_client *uci_handle, } uci_log(UCI_DBG_VERBOSE, - "wk up Got data on ch %d read_data_ready %d\n", + "wk up Got data on ch_id:%d read_data_ready %d\n", uci_handle->in_chan, atomic_read(&uci_handle->read_data_ready)); } else if (*bytes_avail > 0) { /* A valid packet was returned from MHI */ uci_log(UCI_DBG_VERBOSE, - "Got packet: avail pkts %d phy_adr %pK, ch %d\n", + "Got packet: avail pkts %d phy_adr %pK, ch_id:%d\n", atomic_read(&uci_handle->read_data_ready), uci_handle->pkt_loc, uci_handle->in_chan); @@ -1398,7 +1399,7 @@ static ssize_t mhi_uci_client_read(struct file *file, char __user *ubuf, mutex = &uci_handle->in_chan_lock; mutex_lock(mutex); - uci_log(UCI_DBG_VERBOSE, "Client attempted read on chan %d\n", + uci_log(UCI_DBG_VERBOSE, "Client attempted read on ch_id:%d\n", uci_handle->in_chan); ret_val = __mhi_uci_client_read(uci_handle, &bytes_avail); @@ -1418,7 +1419,7 @@ static ssize_t mhi_uci_client_read(struct file *file, char __user *ubuf, bytes_copied = *bytes_pending; *bytes_pending = 0; - uci_log(UCI_DBG_VERBOSE, "Copied 0x%lx of 0x%x, chan %d\n", + uci_log(UCI_DBG_VERBOSE, "Copied 0x%lx of 0x%x, ch_id:%d\n", bytes_copied, (u32)*bytes_pending, uci_handle->in_chan); } else { addr_offset = uci_handle->pkt_size - *bytes_pending; @@ -1429,7 +1430,7 @@ static ssize_t mhi_uci_client_read(struct file *file, char __user *ubuf, } bytes_copied = uspace_buf_size; *bytes_pending -= uspace_buf_size; - uci_log(UCI_DBG_VERBOSE, "Copied 0x%lx of 0x%x,chan %d\n", + uci_log(UCI_DBG_VERBOSE, "Copied 0x%lx of 0x%x,ch_id:%d\n", bytes_copied, (u32)*bytes_pending, uci_handle->in_chan); @@ -1437,7 +1438,7 @@ static ssize_t mhi_uci_client_read(struct file *file, char __user *ubuf, /* We finished with this buffer, map it back */ if (*bytes_pending == 0) { uci_log(UCI_DBG_VERBOSE, - "All data consumed. Pkt loc %p ,chan %d\n", + "All data consumed. Pkt loc %p ,ch_id:%d\n", uci_handle->pkt_loc, uci_handle->in_chan); uci_handle->pkt_loc = 0; uci_handle->pkt_size = 0; @@ -1578,7 +1579,7 @@ void mhi_uci_chan_state_notify_all(struct mhi_dev *mhi, for (i = 0; i < ARRAY_SIZE(mhi_chan_attr_table); i++) { chan_attrib = &mhi_chan_attr_table[i]; if (chan_attrib->state_bcast) { - uci_log(UCI_DBG_ERROR, "Calling notify for ch %d\n", + uci_log(UCI_DBG_ERROR, "Calling notify for ch_id:%d\n", chan_attrib->chan_id); mhi_uci_chan_state_notify(mhi, chan_attrib->chan_id, ch_state); @@ -1595,14 +1596,14 @@ void mhi_uci_chan_state_notify(struct mhi_dev *mhi, int rc; if (ch_id < 0 || ch_id >= MHI_MAX_SOFTWARE_CHANNELS) { - uci_log(UCI_DBG_ERROR, "Invalid chan %d\n", ch_id); + uci_log(UCI_DBG_ERROR, "Invalid ch_id:%d\n", ch_id); return; } uci_handle = &uci_ctxt.client_handles[CHAN_TO_CLIENT(ch_id)]; if (!uci_handle->out_chan_attr || !uci_handle->out_chan_attr->state_bcast) { - uci_log(UCI_DBG_VERBOSE, "Uevents not enabled for chan %d\n", + uci_log(UCI_DBG_VERBOSE, "Uevents not enabled for ch_id:%d\n", ch_id); return; } @@ -1628,7 +1629,7 @@ void mhi_uci_chan_state_notify(struct mhi_dev *mhi, rc = kobject_uevent_env(&mhi->dev->kobj, KOBJ_CHANGE, buf); if (rc) uci_log(UCI_DBG_ERROR, - "Sending uevent failed for chan %d\n", ch_id); + "Sending uevent failed for ch_id:%d\n", ch_id); if (ch_state == MHI_STATE_DISCONNECTED && !atomic_read(&uci_handle->ref_count)) { @@ -1674,7 +1675,7 @@ static void uci_event_notifier(struct mhi_dev_client_cb_reason *reason) uci_handle->out_chan_attr->tre_notif_cb(reason); } else if (reason->reason == MHI_DEV_TRE_AVAILABLE) { uci_log(UCI_DBG_DBG, - "recived TRE available event for chan %d\n", + "recived TRE available event for ch_id:%d\n", uci_handle->in_chan); if (reason->ch_id % 2) { atomic_set(&uci_handle->write_data_ready, 1); @@ -1699,7 +1700,7 @@ static int mhi_register_client(struct uci_client *mhi_client, int index) /* Init the completion event for AT ctrl read */ init_completion(&mhi_client->at_ctrl_read_done); - uci_log(UCI_DBG_DBG, "Registering chan %d.\n", mhi_client->out_chan); + uci_log(UCI_DBG_DBG, "Registering ch_id:%d.\n", mhi_client->out_chan); return 0; } @@ -2066,7 +2067,7 @@ static void mhi_uci_at_ctrl_client_cb(struct mhi_dev_client_cb_data *cb_data) int rc, i; struct mhi_req *ureq; - uci_log(UCI_DBG_VERBOSE, " Rcvd MHI cb for channel %d, state %d\n", + uci_log(UCI_DBG_VERBOSE, " Rcvd MHI cb for ch_id:%d, state %d\n", cb_data->channel, cb_data->ctrl_info); if (cb_data->ctrl_info == MHI_STATE_CONNECTED) { @@ -2117,7 +2118,7 @@ static void mhi_uci_generic_client_cb(struct mhi_dev_client_cb_data *cb_data) { struct uci_client *client = cb_data->user_data; - uci_log(UCI_DBG_DBG, "Rcvd MHI cb for channel %d, state %d\n", + uci_log(UCI_DBG_DBG, "Rcvd MHI cb for ch_id:%d, state %d\n", cb_data->channel, cb_data->ctrl_info); if (cb_data->ctrl_info == MHI_STATE_CONNECTED) From 0700b4628f4415e883eae92444cfafc3afb879e3 Mon Sep 17 00:00:00 2001 From: Nitesh Gupta Date: Tue, 13 Oct 2020 17:22:32 +0530 Subject: [PATCH 47/48] msm: ep_pcie: unset ltssm_en bit in case of link failure In cases where the PCIe enumeration fails after enabling LTSSM in HLOS, we need to set ltssm_en bit properly in order for subsequent enumeration to go through. This change unsets the ltssm_en bit in case of link failure. Change-Id: Ic179f1bbc88523345566c1afa78e5218c872b556 Signed-off-by: Nitesh Gupta --- drivers/platform/msm/ep_pcie/ep_pcie_core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/platform/msm/ep_pcie/ep_pcie_core.c b/drivers/platform/msm/ep_pcie/ep_pcie_core.c index 98c70fb3a75c..684ce0400a5e 100644 --- a/drivers/platform/msm/ep_pcie/ep_pcie_core.c +++ b/drivers/platform/msm/ep_pcie/ep_pcie_core.c @@ -2003,6 +2003,11 @@ int ep_pcie_core_enable_endpoint(enum ep_pcie_options opt) link_fail: dev->power_on = false; + if (dev->phy_rev >= 3) + ep_pcie_write_mask(dev->parf + PCIE20_PARF_LTSSM, BIT(8), 0); + else + ep_pcie_write_mask(dev->elbi + PCIE20_ELBI_SYS_CTRL, BIT(0), 0); + if (!ep_pcie_debug_keep_resource) ep_pcie_pipe_clk_deinit(dev); pipe_clk_fail: From f811f2e80ea47185937a07ff422e6a5b6f571542 Mon Sep 17 00:00:00 2001 From: Mukesh Kumar Savaliya Date: Tue, 1 Mar 2022 13:33:19 +0530 Subject: [PATCH 48/48] i2c: i2c-msm-geni: Report NACK as an error to client if there is a NACK from i2c slave side on the bus while doing i2c transfer, report it as an error. So far NACK reproted at i2c master just as an error and if master is done with the command to GENI, it considered as a success. Ideally the NACK or ACK is part of protocol, here we are returning NACK as an error for the client to take some respective action. Change-Id: I084f8f733310f7a10f2d53f34d9c99f6c5234406 Signed-off-by: Mukesh Kumar Savaliya --- drivers/i2c/busses/i2c-msm-geni.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-msm-geni.c b/drivers/i2c/busses/i2c-msm-geni.c index 0fb48f90b612..9c508aa56efe 100644 --- a/drivers/i2c/busses/i2c-msm-geni.c +++ b/drivers/i2c/busses/i2c-msm-geni.c @@ -1235,11 +1235,15 @@ static int geni_i2c_xfer(struct i2c_adapter *adap, pm_runtime_mark_last_busy(gi2c->dev); pm_runtime_put_autosuspend(gi2c->dev); } + gi2c->cur = NULL; - gi2c->err = 0; - GENI_SE_DBG(gi2c->ipcl, false, gi2c->dev, - "i2c txn ret:%d\n", ret); - return ret; + GENI_SE_ERR(gi2c->ipcl, true, gi2c->dev, + "i2c txn ret:%d, num:%d, err%:%d\n", ret, num, gi2c->err); + + if (gi2c->err) + return gi2c->err; + else + return ret; } static u32 geni_i2c_func(struct i2c_adapter *adap)